Commit 521696f551aef7958a82de2ee63da192d2bc2caa

Authored by Henry Fredrick Schreiner
Committed by Henry Schreiner
1 parent b9492305

Adding Python 2.6 support

Showing 1 changed file with 9 additions and 5 deletions
scripts/MakeSingleHeader.py
... ... @@ -7,9 +7,10 @@ import re
7 7 import argparse
8 8 import operator
9 9 from copy import copy
10   -from subprocess import check_output, CalledProcessError
11 10 from functools import reduce
12 11  
  12 +import subprocess
  13 +
13 14 includes_local = re.compile(r"""^#include "(.*)"$""", re.MULTILINE)
14 15 includes_system = re.compile(r"""^#include \<(.*)\>$""", re.MULTILINE)
15 16 version_finder = re.compile(r"""^#define CLI11_VERSION \"(.*)\"$""", re.MULTILINE)
... ... @@ -44,7 +45,7 @@ class HeaderFile(object):
44 45  
45 46 # add self.verbatim
46 47 if 'CLI11:verbatim' in inner:
47   - self.verbatim = ["\n\n// Verbatim copy from {}:".format(inc)]
  48 + self.verbatim = ["\n\n// Verbatim copy from {0}:".format(inc)]
48 49 self.verbatim += verbatim_all.findall(inner)
49 50 inner = verbatim_all.sub("", inner)
50 51 else:
... ... @@ -52,7 +53,7 @@ class HeaderFile(object):
52 53  
53 54 self.headers = set(includes_system.findall(inner))
54 55  
55   - self.body = '\n// From {}:\n\n'.format(inc) + inner[inner.find('namespace'):]
  56 + self.body = '\n// From {0}:\n\n'.format(inc) + inner[inner.find('namespace'):]
56 57  
57 58 self.namespace = None
58 59  
... ... @@ -111,8 +112,11 @@ class HeaderFile(object):
111 112 def MakeHeader(output, main_header, include_dir = '../include', namespace=None, macro=None):
112 113 # Set tag if possible to class variable
113 114 try:
114   - HeaderFile.TAG = check_output(['git', 'describe', '--tags', '--always'], cwd=str(DIR)).decode("utf-8").strip()
115   - except CalledProcessError:
  115 + proc = subprocess.Popen(['git', 'describe', '--tags', '--always'], cwd=str(DIR), stdout=subprocess.PIPE)
  116 + out, _ = proc.communicate()
  117 + if proc.returncode == 0:
  118 + HeaderFile.TAG = out.decode("utf-8").strip()
  119 + except OSError:
116 120 pass
117 121  
118 122 base_dir = os.path.abspath(os.path.join(DIR, include_dir))
... ...