Imports a repository package using the repository ID specified.
342768
def import_repo(self, repo_id, fileobj):
        '''
        
        '''
        # Step 1, lets upload the file
        filename = self.upload(fileobj).json()['response']['filename']

        # Step 2, lets tell SecurityCenter what to do with the file
        return self.post('repository/{}/import'.format(repo_id), json={'file': filename})
706257
def package_username(repo):
    '''
        

    '''
    package = repo.replace('-', '_')
    username = repo.split('-')[1]
    return package, username
569449
def from_directory_import(
        self,
        module,
        real_names,
        local_names,
        import_alias_mapping,
        skip_init=False
    ):
        
        module_path = module[1]

        init_file_location = os.path.join(module_path, '__init__.py')
        init_exists = os.path.isfile(init_file_location)

        if init_exists and not skip_init:
            package_name = os.path.split(module_path)[1]
            return self.add_module(
                module=(module[0], init_file_location),
                module_or_package_name=package_name,
                local_names=local_names,
                import_alias_mapping=import_alias_mapping,
                is_init=True,
                from_from=True
            )
        for real_name in real_names:
            full_name = os.path.join(module_path, real_name)
            if os.path.isdir(full_name):
                new_init_file_location = os.path.join(full_name, '__init__.py')
                if os.path.isfile(new_init_file_location):
                    self.add_module(
                        module=(real_name, new_init_file_location),
                        module_or_package_name=real_name,
                        local_names=local_names,
                        import_alias_mapping=import_alias_mapping,
                        is_init=True,
                        from_from=True,
                        from_fdid=True
                    )
                else:
                    raise Exception('from anything import directory needs an __init__.py file in directory')
            else:
                file_module = (real_name, full_name + '.py')
                self.add_module(
                    module=file_module,
                    module_or_package_name=real_name,
                    local_names=local_names,
                    import_alias_mapping=import_alias_mapping,
                    from_from=True
                )
        return IgnoredNode()
51190
def createRepoObjects():
	""""""
	repositories = {}
	repodir = os.path.join(getScriptLocation())
	for importer, name, ispkg in pkgutil.iter_modules([repodir]):
		module = importer.find_module(name).load_module(name)
		repo_name = module.name
		if module.enabled:
			repositories[repo_name] = module.getRepository()
	
	return repositories
655718
def import_submodules(package_name, *submodules):
    """"""
    package = sys.modules[package_name]
    return {
        name: importlib.import_module(package_name + '.' + name)
        for _, name, _ in pkgutil.walk_packages(package.__path__)
        if not submodules or name in submodules
    }
1351119
protected void createVersionHistory(ImportNodeData nodeData) throws RepositoryException
   {
      // Generate new VersionHistoryIdentifier and BaseVersionIdentifier
      // if uuid changed after UC
      boolean newVersionHistory = nodeData.isNewIdentifer() || !nodeData.isContainsVersionhistory();
      if (newVersionHistory)
      {
         nodeData.setVersionHistoryIdentifier(IdGenerator.generate());
         nodeData.setBaseVersionIdentifier(IdGenerator.generate());
      }

      PlainChangesLogImpl changes = new PlainChangesLogImpl();
      // using VH helper as for one new VH, all changes in changes log
      new VersionHistoryDataHelper(nodeData, changes, dataConsumer, nodeTypeDataManager,
         nodeData.getVersionHistoryIdentifier(), nodeData.getBaseVersionIdentifier());

      if (!newVersionHistory)
      {
         for (ItemState state : changes.getAllStates())
         {
            if (!state.getData().getQPath().isDescendantOf(Constants.JCR_SYSTEM_PATH))
            {
               changesLog.add(state);
            }
         }
      }
      else
      {
         changesLog.addAll(changes.getAllStates());
      }
   }
152803
def module(self):
        """"""
        # late import to workaround circular dependencies
        module_checkout_abspath = self.abspath
        try:
            repo = git.Repo(module_checkout_abspath)
            if repo != self.repo:
                return repo
            # END handle repo uninitialized
        except (InvalidGitRepositoryError, NoSuchPathError):
            raise InvalidGitRepositoryError("No valid repository at %s" % module_checkout_abspath)
        else:
            raise InvalidGitRepositoryError("Repository at %r was not yet checked out" % module_checkout_abspath)
382121
private void addRepository(String repositoryId, RepositoryWrapper repositoryHolder) {
        repositories.put(repositoryId, repositoryHolder);
        try {
            numRepos = getNumberOfRepositories();
        } catch (WIMException e) {
            // okay
        }
    }
1031023
def NameImport(package, as_name=None, prefix=None):
    
    if prefix is None:
        prefix = u""
    children = [Name(u"import", prefix=prefix), package]
    if as_name is not None:
        children.extend([Name(u"as", prefix=u" "),
                         Name(as_name, prefix=u" ")])
    return Node(syms.import_name, children)
1057097
def to_package(self, repo_url):
        """"""
        return Package(name=self.name, url=repo_url + self.name)
874260
@SuppressWarnings("squid:S2083")
  @PostMapping("/importByUrl")
  @ResponseBody
  public ResponseEntity<String> importFileByUrl(
      HttpServletRequest request,
      @RequestParam("url") String url,
      @RequestParam(value = "entityTypeId", required = false) String entityTypeId,
      @RequestParam(value = "packageId", required = false) String packageId,
      @RequestParam(value = "metadataAction", required = false) String metadataAction,
      @RequestParam(value = "action", required = false) String action,
      @RequestParam(value = "notify", required = false) Boolean notify)
      throws URISyntaxException {
    ImportRun importRun;
    try {
      File tmpFile = fileLocationToStoredRenamedFile(url, entityTypeId);
      if (packageId != null && !dataService.getMeta().getPackage(packageId).isPresent()) {
        return ResponseEntity.badRequest()
            .contentType(TEXT_PLAIN)
            .body(MessageFormat.format("Package [{0}] does not exist.", packageId));
      }
      importRun = importFile(request, tmpFile, metadataAction, action, notify, packageId);
    } catch (Exception e) {
      LOG.error(e.getMessage());
      return ResponseEntity.badRequest().contentType(TEXT_PLAIN).body(e.getMessage());
    }
    return createCreatedResponseEntity(importRun);
  }
972612
public static RepositoryPackage fromPackagist(String name) throws Exception {
		
		PackagistDownloader downloader = new PackagistDownloader();
		return downloader.loadPackage(name);
	}
1266174
private RepositoryId getRepository(final String owner, final String name) throws GitHubException {
		RepositoryId repository = null;
		if(StringUtils.isNotBlank(name) && StringUtils.isNotBlank(owner)){
			repository = RepositoryId.create(owner, name);
		}else{
			throw new GitHubException("No GitHub repository (owner and name) configured");
		}
		if (log.isDebugEnabled()){
			log.debug(MessageFormat.format("Using GitHub repository {0}", repository.generateId()));
		}
		return repository;
	}
1334946
public Repository addRepository(String name,
                                    String url) {
        Repository repository = new Repository(name, url);
        repositories.add(repository);
        return repository;
    }
622618
def touch_import(package, name, node):
    
    def is_import_stmt(node):
        return (node.type == syms.simple_stmt and node.children and
                is_import(node.children[0]))

    root = find_root(node)

    if does_tree_import(package, name, root):
        return

    # figure out where to insert the new import.  First try to find
    # the first import and then skip to the last one.
    insert_pos = offset = 0
    for idx, node in enumerate(root.children):
        if not is_import_stmt(node):
            continue
        for offset, node2 in enumerate(root.children[idx:]):
            if not is_import_stmt(node2):
                break
        insert_pos = idx + offset
        break

    # if there are no imports where we can insert, find the docstring.
    # if that also fails, we stick to the beginning of the file
    if insert_pos == 0:
        for idx, node in enumerate(root.children):
            if (node.type == syms.simple_stmt and node.children and
               node.children[0].type == token.STRING):
                insert_pos = idx + 1
                break

    if package is None:
        import_ = Node(syms.import_name, [
            Leaf(token.NAME, u"import"),
            Leaf(token.NAME, name, prefix=u" ")
        ])
    else:
        import_ = FromImport(package, [Leaf(token.NAME, name, prefix=u" ")])

    children = [import_, Newline()]
    root.insert_child(insert_pos, Node(syms.simple_stmt, children))
440957
def load(self, fname):
        

        # Imports
        import h5py as h5
        from ..error import RepoError

        # If repo not None, complain
        if not self._repo == None:
            raise RepoError(RepoError.STATUS,
                    "Repository already open",
                    "File: {0}".format(self.fname))
        ## end if

        # If string passed, try opening h5.File; otherwise complain
        if isinstance(fname, str):
            self.fname = fname
            self._repo = h5.File(fname)
        else:
            raise TypeError("Invalid filename type: {0}".format(type(fname)))
623234
def import_module(name, package=None):
    
    if name.startswith('.'):
        if not package:
            raise TypeError("relative imports require the 'package' argument")
        level = 0
        for character in name:
            if character != '.':
                break
            level += 1
        name = _resolve_name(name[level:], package, level)
    __import__(name)
    return sys.modules[name]