From 1d13b38fc47b9944a3499ee88c73f3cf849db758 Mon Sep 17 00:00:00 2001 From: Sauci Date: Thu, 12 Jul 2018 07:05:00 -0600 Subject: [PATCH 1/3] add possibility to drop leading and trailing spaces in c.Comment class. --- cgen/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cgen/__init__.py b/cgen/__init__.py index 97a878e..038cf3f 100644 --- a/cgen/__init__.py +++ b/cgen/__init__.py @@ -816,11 +816,15 @@ class Line(Generable): class Comment(Generable): - def __init__(self, text): + def __init__(self, text, skip_space=False): self.text = text + if skip_space is False: + self.fmt_str = "/* %s */" + else: + self.fmt_str = "/*%s*/" def generate(self): - yield "/* %s */" % self.text + yield self.fmt_str % self.text mapper_method = "map_comment" -- GitLab From c7eaec6f90835f9d024cce0a4e2d6424ba22fb8d Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 18 Jul 2018 15:24:10 -0500 Subject: [PATCH 2/3] Fix Comment.skip_space logic --- cgen/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cgen/__init__.py b/cgen/__init__.py index 038cf3f..f42ccd6 100644 --- a/cgen/__init__.py +++ b/cgen/__init__.py @@ -818,10 +818,10 @@ class Line(Generable): class Comment(Generable): def __init__(self, text, skip_space=False): self.text = text - if skip_space is False: - self.fmt_str = "/* %s */" - else: + if skip_space: self.fmt_str = "/*%s*/" + else: + self.fmt_str = "/* %s */" def generate(self): yield self.fmt_str % self.text -- GitLab From 767a2b6292c0e0bab590bddc1e0d42026c4524b1 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 18 Jul 2018 15:24:42 -0500 Subject: [PATCH 3/3] Use submodule module to set version --- cgen/version.py | 3 +++ setup.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 cgen/version.py diff --git a/cgen/version.py b/cgen/version.py new file mode 100644 index 0000000..922dd50 --- /dev/null +++ b/cgen/version.py @@ -0,0 +1,3 @@ +VERSION = (2018, 1) +VERSION_STATUS = "" +VERSION_TEXT = ".".join(str(x) for x in VERSION) + VERSION_STATUS diff --git a/setup.py b/setup.py index 8ab7b03..804c236 100644 --- a/setup.py +++ b/setup.py @@ -6,9 +6,15 @@ from setuptools import setup with open("README.rst", "rt") as inf: readme = inf.read() +ver_dic = {} +with open("cgen/version.py") as version_file: + version_file_contents = version_file.read() + +exec(compile(version_file_contents, "cgen/version.py", 'exec'), ver_dic) + setup( name="cgen", - version="2017.1", + version=ver_dic["VERSION_TEXT"], description="C/C++ source generation from an AST", long_description=readme, classifiers=[ -- GitLab