Initial commit: bare
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 7 Nov 2014 05:36:37 +0000 (00:36 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 7 Nov 2014 05:36:37 +0000 (00:36 -0500)
.gitignore [new file with mode: 0644]
LICENSE [new file with mode: 0644]
barectf/__init__.py [new file with mode: 0644]
barectf/cli.py [new file with mode: 0644]
setup.py [new file with mode: 0755]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..db4561e
--- /dev/null
@@ -0,0 +1,54 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.cache
+nosetests.xml
+coverage.xml
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..bbaf6c3
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Philippe Proulx <philippe.proulx@efficios.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/barectf/__init__.py b/barectf/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/barectf/cli.py b/barectf/cli.py
new file mode 100644 (file)
index 0000000..2f02bd7
--- /dev/null
@@ -0,0 +1,82 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2014 Philippe Proulx <philippe.proulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+from termcolor import cprint, colored
+import argparse
+import sys
+import os
+import re
+
+
+def _perror(msg, exit_code=1):
+    cprint('Error: {}'.format(msg), 'red', attrs=['bold'], file=sys.stderr)
+    sys.exit(exit_code)
+
+
+def _pinfo(msg):
+    cprint(':: {}'.format(msg), 'blue', attrs=['bold'], file=sys.stderr)
+
+
+def _parse_args():
+    ap = argparse.ArgumentParser()
+
+    ap.add_argument('-O', '--output', metavar='OUTPUT', action='store',
+                    default=os.getcwd(),
+                    help='output directory of C files')
+    ap.add_argument('-p', '--prefix', metavar='PREFIX', action='store',
+                    default='barectf',
+                    help='custom prefix for C function and structure names')
+    ap.add_argument('-s', '--static-inline', action='store_true',
+                    help='generate static inline C functions')
+    ap.add_argument('-c', '--manual-clock', action='store_true',
+                    help='do not use a clock callback: pass clock value to tracing functions')
+    ap.add_argument('metadata', metavar='METADATA', action='store',
+                    help='CTF metadata input file')
+
+    # parse args
+    args = ap.parse_args()
+
+    # validate output directory
+    if not os.path.isdir(args.output):
+        _perror('"{}" is not an existing directory'.format(args.output))
+
+    # validate prefix
+    if not re.match(r'^[a-zA-Z_][a-zA-Z0-9_]*$', args.prefix):
+        _perror('"{}" is not a valid C identifier'.format(args.prefix))
+
+    # validate that metadata file exists
+    if not os.path.isfile(args.metadata):
+        _perror('"{}" is not an existing file'.format(args.metadata))
+
+    return args
+
+
+def gen_barectf(output, prefix, static_inline, manual_clock):
+    _pinfo(output)
+    _pinfo(prefix)
+    _pinfo(static_inline)
+    _pinfo(manual_clock)
+
+
+def run():
+    args = _parse_args()
+    gen_barectf(args.output, args.prefix, args.static_inline,
+                args.manual_clock)
diff --git a/setup.py b/setup.py
new file mode 100755 (executable)
index 0000000..798770c
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+#
+# The MIT License (MIT)
+#
+# Copyright (c) 2014 Philippe Proulx <philippe.proulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+import os
+import sys
+import subprocess
+from setuptools import setup
+
+
+# make sure we run Python 3+ here
+v = sys.version_info
+if v.major < 3:
+    sys.stderr.write('Sorry, barectf needs Python 3\n')
+    sys.exit(1)
+
+
+# pyPEG2 needs to be installed manually (for pytsdl) until their PyPI
+# tarball is fixed for setuptools.
+try:
+    import pypeg2
+except ImportError:
+    sys.stderr.write('Please install pyPEG2 manually:\n\n')
+    sys.stderr.write('    sudo pip3 install pyPEG2\n')
+    sys.exit(1)
+
+
+install_requires = [
+  'termcolor',
+  'pytsdl',
+]
+
+
+packages = [
+    'barectf',
+]
+
+
+entry_points = {
+    'console_scripts': [
+        'barectf = barectf.cli:run'
+    ],
+}
+
+
+setup(name='barectf',
+      version=0.1,
+      description='Generator of ANSI C code that can write native CTF',
+      author='Philippe Proulx',
+      author_email='eeppeliteloop@gmail.com',
+      license='MIT',
+      keywords='tsdl ctf metadata',
+      url='https://github.com/eepp/barectf',
+      packages=packages,
+      install_requires=install_requires,
+      entry_points=entry_points)
This page took 0.0271 seconds and 4 git commands to generate.