Esempio n. 1
0
    >>> text = chr(10).join(['# a comment', '#', '', 'foo', 'bar #comment'])
    >>> list(splitLines(text))
    ['foo', 'bar']
    """
    import re

    reg = re.compile("#.*$")
    for line in text.splitlines():
        line = reg.sub("", line).strip()
        if len(line) > 0:
            yield line


@cmds.add(
    [
        ("r", "replace", False, _("Replace the input file with the output")),
        ("p", "print", False, _("Print the output to stdout")),
        ("x", "stop", False, _("Stop processing files on the first error")),
        ("", "diff", False, _("Display the difference between the input file and the output")),
        ("", "show_all", False, _("Show all generated files, not just the ones which are modified")),
    ],
    [
        (
            ("file", "files"),
            [],
            _("C++ files to update with generated code. If empty the file list from the configuration file is used."),
        )
    ],
    mutex=[("replace", "diff")],
)
def cpp(ui, files, replace, verbose, stop, diff, show_all, **kwargs):
Esempio n. 2
0
import shutil
import sys


def check_version(ui):
    from distutils.version import LooseVersion as Version
    if not hasattr(ui, 'version') or not Version(ui.version) > '0.2':
        raise ExtensionError('javagen extension requires hob 0.2 or higher')


cmds = CommandTable()


@cmds.add([
    ('', 'out', '',
     _('write generated code to specified directory (default: "./out")')),
], [
    (('service', 'services'), [],
     _('files to transform into Google Protobuffer compatible .proto files for use with Java'
       )),
])
def java(ui, services, out, **kwargs):
    """Generate Protocol Buffer definitions which are Java compatible"""

    # Use java.conf so that we don't pollute hob's namespace
    java_config = readJavaConfig('./java.conf')

    from hob.proto import PackageManager
    f = sys.stdout
    if out:
        if not os.path.exists(out):
Esempio n. 3
0
import hob
import os
import re
import shutil
import sys

def check_version(ui):
    from distutils.version import LooseVersion as Version
    if not hasattr(ui, 'version') or not Version(ui.version) > '0.2':
        raise ExtensionError('javagen extension requires hob 0.2 or higher')

cmds = CommandTable()

@cmds.add([
        ('', 'out', '',
            _('write generated code to specified directory (default: "./out")')),
        ],
        [(('service', 'services'), [],
            _('files to transform into Google Protobuffer compatible .proto files for use with Java')),
        ])
def java(ui, services, out, **kwargs):
    """Generate Protocol Buffer definitions which are Java compatible"""

    # Use java.conf so that we don't pollute hob's namespace
    java_config = readJavaConfig('./java.conf')

    from hob.proto import PackageManager
    f = sys.stdout
    if out:
        if not os.path.exists(out):
            os.makedirs(out)
Esempio n. 4
0
    >>> list(splitLines(""))
    []
    >>> text = chr(10).join(['# a comment', '#', '', 'foo', 'bar #comment'])
    >>> list(splitLines(text))
    ['foo', 'bar']
    """
    import re
    reg = re.compile("#.*$")
    for line in text.splitlines():
        line = reg.sub("", line).strip()
        if len(line) > 0:
            yield line


@cmds.add([
    ('r', 'replace', False, _("Replace the input file with the output")),
    ('p', 'print', False, _("Print the output to stdout")),
    ('x', 'stop', False, _("Stop processing files on the first error")),
    ('', 'diff', False,
     _("Display the difference between the input file and the output")),
    ('', 'show_all', False,
     _("Show all generated files, not just the ones which are modified")),
], [
    (('file', 'files'), [],
     _("C++ files to update with generated code. If empty the file list from the configuration file is used."
       )),
],
          mutex=[('replace', 'diff')])
def cpp(ui, files, replace, verbose, stop, diff, show_all, **kwargs):
    """Generates/Updates C++ code from protocol buffer definitions.
    """