def extract_repo(self, frm, to): import git_repo_manager pkg_name = frm.split('/')[-1] path = os.path.join(to, self.name, pkg_name) git_clone(self.name, self.remote_url, to) print("Extracting code from {0} to {1}").format(frm, path) copytree(src=frm, dst=path) print("Generating necessary files do create a dist") print(" ... setup.py") with open(os.path.join(git_repo_manager.__path__[0], "templates/setup.py.conf"), 'r') as setup_tmpl: content = setup_tmpl.read() content = content.replace("$name", self.name) content = content.replace("$version", self.version) content = content.replace("$description", self.author) content = content.replace("$long_description", self.long_description) content = content.replace("$keywords", self.keywords) content = content.replace("$author", self.author) content = content.replace("$email", self.email) content = content.replace("$url", self.remote_url) content = content.replace("$pkg_dir", pkg_name) with open(os.path.join(to, self.name, "setup.py"), 'w') as setup_file: setup_file.write(content) print(" ... README.md") with open(os.path.join(git_repo_manager.__path__[0], "templates/README.md.conf"), 'r') as rdm_tmpl: content = rdm_tmpl.read() content = content.replace("$name", self.name) content = content.replace("$description", self.author) with open(os.path.join(to, self.name, "README.md"), 'w') as rdm_file: rdm_file.write(content) self.commit_changes(to) self.tag(to, self.name, self.version)
def main(argv): global config global yaml_file global WORKSPACE global project parser = OptionParser(version=Version) parser.add_option("-c", "--clone", action="store_true", dest="clone", help="Clone a project") parser.add_option("-f", "--file", dest="filename", help="Path do config.yaml", metavar="FILE") parser.add_option("-p", "--push", action="store_true", dest="push", help="Push changes to remote repository") parser.add_option("-u", "--update", action="store_true", dest="update", help="Update repositories.") parser.add_option("-s", "--status", action="store_true", dest="status", help="See repositories statuses.") parser.add_option("-T", "--TAGS", action="store_true", dest="tags", help="Show last tags por all configured repositories") parser.add_option("-t", "--tag", action="store_true", dest="tag", help="Tag a repo or all repos, if none tag is provided") parser.add_option("-r", "--repo", dest="project", metavar="(PROJECT|all)", help="The project as configured in config.yaml") parser.add_option("-d", "--pip-develop", action="store_true", dest="develop", help="Install dependencies in 'develop mode'") (options, args) = parser.parse_args() if not options.filename: print 'You must provide a config.yaml file.' sys.exit(2) yaml_file = options.filename config = yaml.load(open(yaml_file, 'r')) WORKSPACE = config['workspace'] if options.project: project = options.project if not config['projects'].get(options.project): print "Project '%s' is not configured in config.yaml. Please, verify." % project sys.exit(2) else: project = "all" if options.update: if project != 'all': git_update(WORKSPACE, project) else: for repo in config['projects'].keys(): project = repo git_update(WORKSPACE, project) if options.status: if project != 'all': git_status(WORKSPACE, project) else: for repo in config['projects'].keys(): project = repo git_status(WORKSPACE, project) if options.clone: if project != 'all': git_clone(project=project, url=config['projects'][project]['repo'], workspace=WORKSPACE) else: print "Cloning %s" % ', '.join(config['projects'].keys()) for repo in config['projects'].keys(): git_clone(project=repo, url=config['projects'][repo]['repo'], workspace=WORKSPACE) elif options.push: if project != 'all': git_push(WORKSPACE, config['projects'][project]['name']) else: print "Pushing %s" % ', '.join(config['projects'].keys()) for repo in config['projects'].keys(): project = repo git_push() elif options.tags: if project != 'all': get_last_tag(WORKSPACE, project) else: print "Getting last tags for %s" % ', '.join(config['projects'].keys()) for repo in config['projects'].keys(): project = repo get_last_tag(WORKSPACE, project) elif options.tag: if project != 'all': git_tag() else: print "Tagging projects %s" % ', '.join(config['projects'].keys()) for repo in config['projects'].keys(): project = repo git_tag() elif options.develop: if project != 'all': develop_install() else: print "Installing projects %s" % ', '.join(config['projects'].keys()) for repo in config['projects'].keys(): project = repo develop_install()