def define_jobs_context(self, context): options = self.get_options() dirname = options.dir if not os.path.exists(dirname): msg = "Path does not exist: %r." % dirname raise UserError(msg) from conf_tools.utils import locate_files # @UnresolvedImport bags = list(locate_files(dirname, pattern="*.bag", followlinks=True)) self.info('I found %d bags in %s' % (len(bags), dirname)) if len(bags) == 0: msg = "Could not find any bag in %r." % dirname raise UserError(msg) def short(f): return os.path.splitext(os.path.basename(f))[0] for f in bags: s = short(f) context.comp_dynamic(process, bag_filename=f, tmpdir=options.tmpdir, models=['bag2mp4_fixfps'], job_id=s)
def find_modules(root): """ Looks for modules defined in packages that have the structure: :: dirname/setup.py dirname/src/ dirname/src/module/__init__.py dirname/src/module/module2/__init__.py This will yield ['module', 'module.module2'] """ setups = locate_files(root, 'setup.py') for s in setups: # look for '__init__.py' base = join(dirname(s), 'src') for i in locate_files(base, '__init__.py'): p = os.path.relpath(i, base) components = p.split('/')[:-1] # remove __init__ module = ".".join(components) yield module
def create_event_for_fcpx(dirname, pattern, event_filename=None, event_name=None): """ Creates an index Event for final cut pro X """ if event_filename is None: event_filename = os.path.join(dirname, 'event.fcpxml') if event_name is None: event_name = os.path.basename(dirname) + '-event' filenames = list(locate_files(dirname, pattern)) videos = [get_info_for_file(f, event_filename) for f in filenames] xml_index = fcpx_get_xml_event(videos, event_name) with open(event_filename, 'w') as f: f.write(xml_index.strip()) print('written %s' % friendly_path(event_filename))
import os from conf_tools.utils import locate_files extensions = [ 'mcdp', 'mcdp_poset', 'mcdp_template', 'mcdp_primitivedp', 'mcdp_value' ] for ext in extensions: filenames = locate_files('src', '*' + ext) for f in filenames: dirname = os.path.dirname(f) if 'shelf' in dirname and not dirname.endswith( 'mcdplib') and not 'old' in dirname: print f