def write_common(transforms, init, values): if values['example']: write_template( path.join(transforms, '__init__.py'), init + generate_all('common', 'helloworld') ) write_template( path.join(transforms, 'helloworld.py'), read_template('transform', values) ) else: write_template( path.join(transforms, '__init__.py'), init + generate_all('common') ) write_template( path.join(transforms, 'common', '__init__.py'), init + generate_all('entities') ) write_template( path.join(transforms, 'common', 'entities.py'), read_template('entities', values) )
def write_common(transforms, init, values): if values["example"]: write_template(path.join(transforms, "__init__.py"), init + generate_all("common", "helloworld")) write_template(path.join(transforms, "helloworld.py"), read_template("transform", values)) else: write_template(path.join(transforms, "__init__.py"), init + generate_all("common")) write_template(path.join(transforms, "common", "__init__.py"), init + generate_all("entities")) write_template(path.join(transforms, "common", "entities.py"), read_template("entities", values))
def write_setup(package_name, values): write_template(path.join(package_name, '.canari'), read_template('_canari', values)) write_template(path.join(package_name, 'setup.py'), read_template('setup', values)) write_template(path.join(package_name, 'README.md'), read_template('README', values)) write_template(path.join(package_name, 'MANIFEST.in'), read_template('MANIFEST', values))
def run(args): opts = parse_args(args) initf = path.join(opts.transform_dir, '__init__.py') transform = opts.transform if not opts.transform.endswith('.py') else opts.transform[:-3] if '.' in transform: print "Transform name (%s) cannot have a dot ('.')." % repr(transform) exit(-1) elif not transform: print "You must specify a valid transform name." exit(-1) directory = opts.transform_dir transformf = path.join(directory, opts.transform if opts.transform.endswith('.py') else '%s.py' % opts.transform ) if not path.exists(initf): print ('Directory %s does not appear to be a python package directory... quitting!' % repr(opts.transform_dir)) exit(-1) if path.exists(transformf): print ('Transform %s already exists... quitting' % repr(transformf)) exit(-1) values = init_pkg() write_template( transformf, read_template('newtransform', values) ) print ('updating %s' % initf) init = file(initf).read() with file(initf, mode='wb') as w: w.write( sub( r'__all__\s*\=\s*\[', '__all__ = [\n %s,' % repr(transform), init ) ) print ('done!')
def create_transform(args): opts = parse_args(args) initf = os.path.join(opts.transform_dir, '__init__.py') transform = opts.transform if not opts.transform.endswith('.py') else opts.transform[:-3] if '.' in transform: print "Transform name (%s) cannot have a dot ('.')." % repr(transform) exit(-1) elif not transform: print "You must specify a valid transform name." exit(-1) directory = opts.transform_dir transformf = os.path.join(directory, opts.transform if opts.transform.endswith('.py') else '%s.py' % opts.transform) if not os.path.exists(initf): print ('Directory %s does not appear to be a python package directory... quitting!' % repr(opts.transform_dir)) exit(-1) if os.path.exists(transformf): print ('Transform %s already exists... quitting' % repr(transformf)) exit(-1) values = init_pkg() write_template( transformf, read_template('newtransform', values) ) print ('updating %s' % initf) init = file(initf).read() with file(initf, mode='wb') as w: w.write( re.sub( r'__all__\s*\=\s*\[', '__all__ = [\n %s,' % repr(transform), init ) ) print ('done!')
def write_setup(base_dir, values): plume_sh = os.path.join(base_dir, 'plume.sh') write_template(os.path.join(base_dir, 'canari.conf'), read_template('canari', values)) write_template(os.path.join(base_dir, 'plume.py'), read_template('plume_wsgi', values)) write_template(plume_sh, read_template('plume_sh', values)) os.chmod(plume_sh, 0755)
def run(args): opts = parse_args(args) initf = path.join(opts.transform_dir, '__init__.py') transform = opts.transform directory = opts.transform_dir transformf = path.join(directory, transform if transform.endswith('.py') else '%s.py' % transform ) if not path.exists(initf): print ('Directory %s does not appear to be a python package directory... quitting!' % repr(opts.transform_dir)) exit(-1) if path.exists(transformf): print ('Transform %s already exists... quitting' % repr(transformf)) exit(-1) values = init_pkg() write_template( transformf, read_template('newtransform', values) ) print ('updating %s' % initf) init = file(initf).read() with file(initf, mode='wb') as w: w.write( sub( r'__all__\s*\=\s*\[', '__all__ = [\n %s,' % repr(transform), init ) ) print ('done!')
def write_root(base, init): write_template( path.join(base, '__init__.py'), init + generate_all('resources', 'transforms') )
def write_resources(package_name, resources, init, values): write_template( path.join(resources, '__init__.py'), init + generate_all('etc', 'images', 'maltego', 'external') ) write_template( path.join(resources, 'etc', '__init__.py'), init ) write_template( path.join(resources, 'images', '__init__.py'), init ) write_template( path.join(resources, 'external', '__init__.py'), init ) write_template( path.join(resources, 'maltego', '__init__.py'), init ) write_template( path.join(resources, 'etc', '%s.conf' % package_name), read_template('conf', values) )
def write_resources(package_name, resources, init, values): write_template(path.join(resources, "__init__.py"), init + generate_all("etc", "images", "maltego", "external")) write_template(path.join(resources, "etc", "__init__.py"), init) write_template(path.join(resources, "images", "__init__.py"), init) write_template(path.join(resources, "external", "__init__.py"), init) write_template(path.join(resources, "maltego", "__init__.py"), init) write_template(path.join(resources, "etc", "%s.conf" % package_name), read_template("conf", values))
def write_root(base, init): write_template(path.join(base, "__init__.py"), init + generate_all("resources", "transforms"))
def write_setup(package_name, values): write_template(path.join(package_name, ".canari"), read_template("_canari", values)) write_template(path.join(package_name, "setup.py"), read_template("setup", values)) write_template(path.join(package_name, "README.md"), read_template("README", values)) write_template(path.join(package_name, "MANIFEST.in"), read_template("MANIFEST", values))