Create a gemspec file from project metadata.
963863
def create_gemspec(file=nil)
      file = gemspec if !file
      #require 'gemdo/gemspec'
      yaml = project.to_gemspec.to_yaml
      File.open(file, 'w') do |f|
        f << yaml
      end
      status File.basename(file) + " updated."
      return file
    end
1108298
def build_specfiles(source, target, env):
    
    #
    # At first we care for the CONTROL/control file, which is the main file for ipk.
    #
    # For this we need to open multiple files in random order, so we store into
    # a dict so they can be easily accessed.
    #
    #
    opened_files={}
    def open_file(needle, haystack):
        try:
            return opened_files[needle]
        except KeyError:
            file=filter(lambda x: x.get_path().rfind(needle)!=-1, haystack)[0]
            opened_files[needle]=open(file.get_abspath(), 'w')
            return opened_files[needle]

    control_file=open_file('control', target)

    if 'X_IPK_DESCRIPTION' not in env:
        env['X_IPK_DESCRIPTION']="%s\n %s"%(env['SUMMARY'],
                                            env['DESCRIPTION'].replace('\n', '\n '))


    content = """
Package: $NAME
Version: $VERSION
Priority: $X_IPK_PRIORITY
Section: $X_IPK_SECTION
Source: $SOURCE_URL
Architecture: $ARCHITECTURE
Maintainer: $X_IPK_MAINTAINER
Depends: $X_IPK_DEPENDS
Description: $X_IPK_DESCRIPTION
"""

    control_file.write(env.subst(content))

    #
    # now handle the various other files, which purpose it is to set post-, 
    # pre-scripts and mark files as config files.
    #
    # We do so by filtering the source files for files which are marked with
    # the "config" tag and afterwards we do the same for x_ipk_postrm,
    # x_ipk_prerm, x_ipk_postinst and x_ipk_preinst tags.
    #
    # The first one will write the name of the file into the file
    # CONTROL/configfiles, the latter add the content of the x_ipk_* variable
    # into the same named file.
    #
    for f in [x for x in source if 'PACKAGING_CONFIG' in dir(x)]:
        config=open_file('conffiles')
        config.write(f.PACKAGING_INSTALL_LOCATION)
        config.write('\n')

    for str in 'POSTRM PRERM POSTINST PREINST'.split():
        name="PACKAGING_X_IPK_%s"%str
        for f in [x for x in source if name in dir(x)]:
            file=open_file(name)
            file.write(env[str])

    #
    # close all opened files
    for f in list(opened_files.values()):
        f.close()

    # call a user specified function
    if 'CHANGE_SPECFILE' in env:
        content += env['CHANGE_SPECFILE'](target)

    return 0
1299445
def _create_projects_file(project_name, data_source, items):
    

    repositories = []
    for item in items:
        if item['origin'] not in repositories:
            repositories.append(item['origin'])
    projects = {
        project_name: {
            data_source: repositories
        }
    }

    projects_file, projects_file_path = tempfile.mkstemp(prefix='track_items_')

    with open(projects_file_path, "w") as pfile:
        json.dump(projects, pfile, indent=True)

    return projects_file_path
435604
def load_gems_in(*spec_dirs)
      @gems.clear

      spec_dirs.reverse_each do |spec_dir|
        spec_files = Dir.glob File.join(spec_dir, '*.gemspec')

        spec_files.each do |spec_file|
          gemspec = self.class.load_specification spec_file.untaint
          add_spec gemspec if gemspec
        end
      end

      self
    end
2860
def generate_plugin_set(*args)
      plugin_path = args.detect{|i| i.is_a?(Pathname) } || plugin_gem_path
      skip = args.detect{|i| i.is_a?(Array) } || []
      plugin_set = PluginSet.new
      @logger.debug("Generating new plugin set instance. Skip gems - #{skip}")
      Dir.glob(plugin_path.join('specifications/*.gemspec').to_s).each do |spec_path|
        spec = Gem::Specification.load(spec_path)
        desired_spec_path = File.join(spec.gem_dir, "#{spec.name}.gemspec")
        # Vendor set requires the spec to be within the gem directory. Some gems will package their
        # spec file, and that's not what we want to load.
        if !File.exist?(desired_spec_path) || !FileUtils.cmp(spec.spec_file, desired_spec_path)
          File.write(desired_spec_path, spec.to_ruby)
        end
        next if skip.include?(spec.name) || skip.include?(spec.full_name)
        plugin_set.add_vendor_gem(spec.name, spec.gem_dir)
      end
      plugin_set
    end
452997
def projects_from_cli(args):
    """"""
    description = ('Determine if a set of project dependencies will work with '
                   'Python 3')
    parser = argparse.ArgumentParser(description=description)
    req_help = 'path(s) to a pip requirements file (e.g. requirements.txt)'
    parser.add_argument('--requirements', '-r', nargs='+', default=(),
                        help=req_help)
    meta_help = 'path(s) to a PEP 426 metadata file (e.g. PKG-INFO, pydist.json)'
    parser.add_argument('--metadata', '-m', nargs='+', default=(),
                        help=meta_help)
    parser.add_argument('--projects', '-p', nargs='+', default=(),
                        help='name(s) of projects to test for Python 3 support')
    parser.add_argument('--verbose', '-v', action='store_true',
                        help='verbose output (e.g. list compatibility overrides)')
    parsed = parser.parse_args(args)

    if not (parsed.requirements or parsed.metadata or parsed.projects):
        parser.error("Missing 'requirements', 'metadata', or 'projects'")

    projects = []
    if parsed.verbose:
        logging.getLogger('ciu').setLevel(logging.INFO)
    projects.extend(projects_.projects_from_requirements(parsed.requirements))
    metadata = []
    for metadata_path in parsed.metadata:
        with io.open(metadata_path) as file:
            metadata.append(file.read())
    projects.extend(projects_.projects_from_metadata(metadata))
    projects.extend(map(packaging.utils.canonicalize_name, parsed.projects))

    return projects
128746
def create_project(project_name, template="default"):
    

    project_dir = get_project_dir_path(project_name)

    run_tpl = pkg_resources.resource_string(__name__, '%s/run.py' % (SKELETON_DIR))
    init_py_tpl = pkg_resources.resource_string(__name__, '%s/init.py' % (SKELETON_DIR))
    deployapp_tpl = pkg_resources.resource_string(__name__, '%s/deployapp.yml' % (SKELETON_DIR))
    config_tpl = pkg_resources.resource_string(__name__, '%s/config.py' % (SKELETON_DIR))
    model_tpl = pkg_resources.resource_string(__name__, '%s/model.py' % (SKELETON_DIR))
    manage_tpl = pkg_resources.resource_string(__name__, '%s/manage.py' % (SKELETON_DIR))

    run_file = "%s/run_%s.py" % (CWD, project_name)
    requirements_txt = "%s/requirements.txt" % CWD
    deployapp_yml = "%s/deployapp.yml" % CWD
    config_py = "%s/config.py" % APPLICATION_DIR
    model_py = "%s/model.py" % APPLICATION_DIR
    manage_py = "%s/manage.py" % CWD

    if not os.path.isdir(APPLICATION_DIR):
        os.makedirs(APPLICATION_DIR)

    if not os.path.isdir(project_dir):
        os.makedirs(project_dir)

    _app_init_py = "%s/__init__.py" % APPLICATION_DIR
    if not os.path.isfile(_app_init_py):
        with open(_app_init_py, "wb") as f:
            f.write(init_py_tpl)

    _init_py = "%s/__init__.py" % CWD
    if not os.path.isfile(_init_py):
        with open(_init_py, "wb") as f:
            f.write("# Pylot")

    if not os.path.isfile(config_py):
        with open(config_py, "wb") as f:
            f.write(config_tpl)

    if not os.path.isfile(model_py):
        with open(model_py, "wb") as f:
            f.write(model_tpl)

    if not os.path.isfile(run_file):
        with open(run_file, "wb") as f:
            f.write(run_tpl.format(project_name=project_name))

    if not os.path.isfile(requirements_txt):
        with open(requirements_txt, "wb") as f:
            f.write("%s==%s" % (PACKAGE.NAME, PACKAGE.__version__))

    if not os.path.isfile(deployapp_yml):
        with open(deployapp_yml, "wb") as f:
            f.write(deployapp_tpl)

    if not os.path.isfile(manage_py):
        with open(manage_py, "wb") as f:
            f.write(manage_tpl)

    copy_resource("%s/%s/" % (SKELETON_DIR, template), project_dir)
502429
def build_clonespec(config_spec, object_ref, reloc_spec, template):
    '''
    
    '''
    if reloc_spec.diskMoveType == QUICK_LINKED_CLONE:
        return vim.vm.CloneSpec(
            template=template,
            location=reloc_spec,
            config=config_spec,
            snapshot=object_ref.snapshot.currentSnapshot
        )

    return vim.vm.CloneSpec(
        template=template,
        location=reloc_spec,
        config=config_spec
    )
701599
def load_from(gemspec_path, pattern)
      Gem.refresh
      spec = Gem::Specification.load(gemspec_path)
      dependencies = spec.runtime_dependencies.concat(spec.development_dependencies)
      dependencies.each do |gem|
        gem_name = gem.name[pattern]
        next if gem_name.to_s.empty?
        register(gem_name, Plugin.new(gem_name, gem))
      end
      self
    end
207893
def build_spec(user, repo, sha=None, prov=None, extraMetadata=[]):
    """"""
    loader = grlc.utils.getLoader(user, repo, sha=sha, prov=prov)

    files = loader.fetchFiles()
    raw_repo_uri = loader.getRawRepoUri()

    # Fetch all .rq files
    items = []

    allowed_ext = ["rq", "sparql", "json", "tpf"]
    for c in files:
        glogger.debug('>>>>>>>>>>>>>>>>>>>>>>>>>c_name: {}'.format(c['name']))
        extension = c['name'].split('.')[-1]
        if extension in allowed_ext:
            call_name = c['name'].split('.')[0]

            # Retrieve extra metadata from the query decorators
            query_text = loader.getTextFor(c)

            item = None
            if extension == "json":
                query_text = json.loads(query_text)

            if extension in ["rq", "sparql", "json"]:
                glogger.debug("===================================================================")
                glogger.debug("Processing SPARQL query: {}".format(c['name']))
                glogger.debug("===================================================================")
                item = process_sparql_query_text(query_text, loader, call_name, extraMetadata)
            elif "tpf" == extension:
                glogger.debug("===================================================================")
                glogger.debug("Processing TPF query: {}".format(c['name']))
                glogger.debug("===================================================================")
                item = process_tpf_query_text(query_text, raw_repo_uri, call_name, extraMetadata)
            else:
                glogger.info("Ignoring unsupported source call name: {}".format(c['name']))

            if item:
                items.append(item)
    return items
723488
def create(output_dir):
    """"""
    template_path = os.path.join(os.path.dirname(__file__), 'project_template')

    click.secho('Let\'s create a new component!', fg='green')
    name = click.prompt('What is the name of this component (ex. python-pip)?')

    click.secho('')
    click.secho('We assume this will be pushed to GitHub and Docker Hub eventually, but these don\'t have to exist yet.', fg='green')
    repo_owner = click.prompt('GitHub repo owner (i.e. your username or organization name)')
    repo_name = click.prompt('GitHub repo name', default=name)
    dockerhub_owner = click.prompt('Docker Hub repo owner', default=repo_owner)
    dockerhub_name = click.prompt('Docker Hub repo name', default=repo_name)

    license_owner = click.prompt('Who should be the copyright owner on project?', default=repo_owner)

    extra_context = {
        'name': name,
        'name_shields_io': name.replace('-', '--'),
        'current_year': datetime.datetime.now().year,
        'dependencies_cli_version': __version__,
        'repo_owner': repo_owner,
        'repo_name': repo_name,
        'dockerhub_owner': dockerhub_owner,
        'dockerhub_name': dockerhub_name,
        'license_owner': license_owner,
    }
    project_dir = cookiecutter(template_path, no_input=True, extra_context=extra_context, output_dir=output_dir)

    click.secho('')
    click.secho('{name} is ready to go, `cd {project_dir}` and try running `dependencies test`!'.format(name=name, project_dir=project_dir), fg='green')
    click.secho(
        'We started you out with a fully functioning component based in python.\n' +
        'Once you\'ve got a handle on how it works then you can change it to whatever language you want.'
    )
408140
def build_model_classes(metadata):
    """"""
    i = importlib.import_module(metadata)
    env = get_jinja_env()
    model_template = env.get_template('model.py.jinja2')
    for model in i.models:
        with open(model_path(model.name.lower()), 'w') as t:
            t.write(model_template.render(model_md=model))
351358
def create_new(projectname):
    """"""
    git_url = "https://github.com/moluwole/Bast_skeleton"
    path = os.path.abspath('.') + "/" + projectname
    if not os.path.exists(path):
        os.makedirs(path)

    click.echo(Fore.GREEN + '    ___  ___   __________')
    click.echo(Fore.GREEN + '  / _ )/ _ | / __/_  __/')
    click.echo(Fore.GREEN + ' / _  / __ |_\ \  / /')
    click.echo(Fore.GREEN + '/____/_/ |_/___/ /_/')

    click.echo(Fore.GREEN + "Creating Project at %s.... " % path)
    click.echo(Fore.GREEN + "Pulling Project Skeleton from Repo")
    try:
        Repo.clone_from(git_url, path)

        click.echo(Fore.GREEN + "Setting up project")

        shutil.rmtree(path + "/.git")

        if not os.path.exists('/.env'):
            shutil.copy(path + '/.env.example', path + '/.env')

        env_file = path + "/.env"
        if not os.path.isfile(env_file):
            shutil.copy('.env.example', '.env')
        call(['panther', 'generate:key', path])

        click.echo(Fore.GREEN + "New Bast Project created at  %s " % path)
    except Exception as e:
        click.echo(Fore.RED + "An error occurred creating a new project. Try Again.\n Reason: {}".format(e))
420041
def autogen(project_path):
    """"""
    generate_quickstart(project_path)

    project = StatikProject(project_path)
    project.config = StatikConfig(project.config_file_path)

    models = list(project.load_models().values())

    logger.info('Creating view and template for home page (index.html).')
    generate_yaml_file(os.path.join(project_path, StatikProject.VIEWS_DIR, 'index.yaml'),
                        {   
                            'path': '/',
                            'template': 'index'
                        }
    )
    generate_index_file(os.path.join(project_path, StatikProject.TEMPLATES_DIR, 'index.jinja2'))

    for model in models:
        logger.info('Creating view and template for model: %s' % model.name)
        generate_yaml_file(os.path.join(project_path, StatikProject.VIEWS_DIR, '%s.yaml' % model.name),
                            {   
                                'path': {
                                    'template': '/%s/{{ %s.pk }}' % (model.name, model.name),
                                    'for-each': {
                                        '%s' % model.name: 'session.query(%s).all()' % model.name
                                    }
                                },
                                'template': ('%s' % model.name),
                            }
        )
        generate_model_file(os.path.join(project_path, StatikProject.TEMPLATES_DIR, '%s.jinja2' % model.name),
                            project,
                            model,
                            model.fields.values())
288957
def gemspec_filename(gem_version = nil)
      gem_version ||= version.to_s
      n = [name, gem_version]
      n.push(@platform) if @platform != 'ruby'
      "#{n.join('-')}.gemspec.rz"
    end
13244
def generate_require_paths
      return configured_require_paths unless gemspec?
      result = []
      gemspecs.each do |file|
        base = File.dirname(file)
        # @todo Evaluating gemspec files violates the goal of not running
        #   workspace code, but this is how Gem::Specification.load does it
        #   anyway.
        begin
          spec = eval(File.read(file), binding, file)
          next unless Gem::Specification === spec
          result.concat(spec.require_paths.map { |path| File.join(base, path) })
        rescue Exception => e
          # Don't die if we have an error during eval-ing a gem spec.
          # Concat the default lib directory instead.
          Solargraph.logger.warn "Error reading #{file}: [#{e.class}] #{e.message}"
          result.push File.join(base, 'lib')
        end
      end
      result.concat config.require_paths
      result.push File.join(directory, 'lib') if result.empty?
      result
    end
426641
def build
      trace "gem build #{gemspec}"
      spec = load_gemspec
      package = ::Gem::Package.build(spec)
      mkdir_p(pkgdir) unless File.directory?(pkgdir)
      mv(package, pkgdir)
    end