Adds a new specfile entry to MsrunContainer.info. See also
        :class:`MsrunContainer.addSpecfile()`.

        :param specfile: the name of an ms-run file
        :param path: filedirectory used for loading and saving ``mrc`` files
513272
def _addSpecfile(self, specfile, path):
        
        datatypeStatus = {'rm': False, 'ci': False, 'smi': False, 'sai': False,
                          'si': False
                          }
        self.info[specfile] = {'path': path, 'status': datatypeStatus}
1355821
def add_to_archive(self, spec):
        '''
        
        '''
        if isinstance(spec, InsightsCommand):
            archive_path = os.path.join(self.cmd_dir, spec.archive_path.lstrip('/'))
        if isinstance(spec, InsightsFile):
            archive_path = self.get_full_archive_path(spec.archive_path.lstrip('/'))
        output = spec.get_output()
        if output:
            write_data_to_file(output, archive_path)
444433
def add_sdfile(self, sdfile):
        
        if not isinstance(sdfile, SDfile):
            raise ValueError('Not a SDfile type: "{}"'.format(type(sdfile)))

        for entry_id in sdfile:
            self.add_molfile(molfile=sdfile[entry_id]['molfile'],
                             data=sdfile[entry_id]['data'])
705727
def add_unique_runid(testcase, run_id=None):
    
    testcase["description"] = '{}<br id="{}"/>'.format(
        testcase.get("description") or "", run_id or id(add_unique_runid)
    )
194966
def GetFileEntryByPathSpec(self, path_spec):
    
    store_index = vshadow.VShadowPathSpecGetStoreIndex(path_spec)

    # The virtual root file has not corresponding store index but
    # should have a location.
    if store_index is None:
      location = getattr(path_spec, 'location', None)
      if location is None or location != self.LOCATION_ROOT:
        return None

      return vshadow_file_entry.VShadowFileEntry(
          self._resolver_context, self, path_spec, is_root=True,
          is_virtual=True)

    if store_index < 0 or store_index >= self._vshadow_volume.number_of_stores:
      return None

    return vshadow_file_entry.VShadowFileEntry(
        self._resolver_context, self, path_spec)
694803
def FileEntryExistsByPathSpec(self, path_spec):
    
    location = getattr(path_spec, 'location', None)

    if (location is None or
        not location.startswith(self.LOCATION_ROOT)):
      return False

    if len(location) == 1:
      return True

    try:
      self._tar_file.getmember(location[1:])
      return True
    except KeyError:
      pass

    # Check if location could be a virtual directory.
    for name in iter(self._tar_file.getnames()):
      # The TAR info name does not have the leading path separator as
      # the location string does.
      if name.startswith(location[1:]):
        return True

    return False
654295
def add_tagfile(self, path, timestamp=None):
        # type: (Text, datetime.datetime) -> None
        """"""
        self.self_check()
        checksums = {}
        # Read file to calculate its checksum
        if os.path.isdir(path):
            return
            # FIXME: do the right thing for directories
        with open(path, "rb") as tag_file:
            # FIXME: Should have more efficient open_tagfile() that
            # does all checksums in one go while writing through,
            # adding checksums after closing.
            # Below probably OK for now as metadata files
            # are not too large..?

            checksums[SHA1] = checksum_copy(tag_file, hasher=hashlib.sha1)

            tag_file.seek(0)
            checksums[SHA256] = checksum_copy(tag_file, hasher=hashlib.sha256)

            tag_file.seek(0)
            checksums[SHA512] = checksum_copy(tag_file, hasher=hashlib.sha512)

        rel_path = _posix_path(os.path.relpath(path, self.folder))
        self.tagfiles.add(rel_path)
        self.add_to_manifest(rel_path, checksums)
        if timestamp is not None:
            self._file_provenance[rel_path] = {"createdOn": timestamp.isoformat()}
329478
def FileEntryExistsByPathSpec(self, path_spec):
    
    location = getattr(path_spec, 'location', None)
    if location is None or not location.startswith(self.LOCATION_ROOT):
      return False

    if len(location) == 1:
      return True

    return self._cpio_archive_file.FileEntryExistsByPath(location[1:])
263943
def GetTSKFileByPathSpec(self, path_spec):
    
    # Opening a file by inode number is faster than opening a file
    # by location.
    inode = getattr(path_spec, 'inode', None)
    location = getattr(path_spec, 'location', None)

    if inode is not None:
      tsk_file = self._tsk_file_system.open_meta(inode=inode)
    elif location is not None:
      tsk_file = self._tsk_file_system.open(location)
    else:
      raise errors.PathSpecError(
          'Path specification missing inode and location.')

    return tsk_file
406892
def build_specfile(target, source, env):
    
    file = open(target[0].get_abspath(), 'w')

    try:
        file.write( build_specfile_header(env) )
        file.write( build_specfile_sections(env) )
        file.write( build_specfile_filesection(env, source) )
        file.close()

        # call a user specified function
        if 'CHANGE_SPECFILE' in env:
            env['CHANGE_SPECFILE'](target, source)

    except KeyError as e:
        raise SCons.Errors.UserError( '"%s" package field for RPM is missing.' % e.args[0] )
626823
def _ReadSpecificationFile(self, path):
    
    specification_store = specification.FormatSpecificationStore()

    with io.open(
        path, 'rt', encoding=self._SPECIFICATION_FILE_ENCODING) as file_object:
      for line in file_object.readlines():
        line = line.strip()
        if not line or line.startswith('#'):
          continue

        try:
          identifier, offset, pattern = line.split()
        except ValueError:
          logger.error('[skipping] invalid line: {0:s}'.format(line))
          continue

        try:
          offset = int(offset, 10)
        except ValueError:
          logger.error('[skipping] invalid offset in line: {0:s}'.format(line))
          continue

        try:
          # TODO: find another way to do this that doesn't use an undocumented
          # API.
          pattern = codecs.escape_decode(pattern)[0]
        # ValueError is raised e.g. when the patterns contains "\xg1".
        except ValueError:
          logger.error(
              '[skipping] invalid pattern in line: {0:s}'.format(line))
          continue

        format_specification = specification.FormatSpecification(identifier)
        format_specification.AddNewSignature(pattern, offset=offset)
        specification_store.AddSpecification(format_specification)

    return specification_store
1370456
def set_file_mode(path, spec, fd=None):
    
    if isinstance(spec, int):
        new_mode = spec
    elif not mitogen.core.PY3 and isinstance(spec, long):
        new_mode = spec
    elif spec.isdigit():
        new_mode = int(spec, 8)
    else:
        mode = os.stat(path).st_mode
        new_mode = apply_mode_spec(spec, mode)

    if fd is not None and hasattr(os, 'fchmod'):
        os.fchmod(fd, new_mode)
    else:
        os.chmod(path, new_mode)
1051483
public void addFile(VariantFileMetadata fileMetadata, String studyId) {
        // Sanity check
        if (fileMetadata == null || StringUtils.isEmpty(fileMetadata.getId())) {
            logger.error("Variant file metadata (or its ID) is null or empty.");
            return;
        }

        VariantStudyMetadata variantStudyMetadata = getVariantStudyMetadata(studyId);
        if (variantStudyMetadata == null) {
            logger.error("Study not found. Check your study ID: '{}'", studyId);
            return;
        }
        if (variantStudyMetadata.getFiles() == null) {
            variantStudyMetadata.setFiles(new ArrayList<>());
        }
        for (VariantFileMetadata file: variantStudyMetadata.getFiles()) {
            if (file.getId() != null && file.getId().equals(fileMetadata.getId())) {
                logger.error("Variant file metadata with id '{}' already exists in study '{}'", fileMetadata.getId(),
                        studyId);
                return;
            }
        }
        // individual management
        if (variantStudyMetadata.getIndividuals() == null) {
            variantStudyMetadata.setIndividuals(new ArrayList<>());
        }
        if (!variantStudyMetadata.getIndividuals().isEmpty()) {
            // check if samples are already in study
            for (String sampleId: fileMetadata.getSampleIds()) {
                for (org.opencb.biodata.models.metadata.Individual individual: variantStudyMetadata.getIndividuals()) {
                    for (Sample sample: individual.getSamples()) {
                        if (sampleId.equals(sample.getId())) {
                            logger.error("Sample '{}' from file {} already exists in study '{}'",
                                    sampleId, fileMetadata.getId(), studyId);
                            return;
                        }
                    }
                }
            }
        }
        // by default, create individuals from sample, and individual ID takes the sample ID
        // TODO: manage multiple samples per individual
        for (String sampleId: fileMetadata.getSampleIds()) {
            List<Sample> samples = new ArrayList<>();
            Sample sample = new Sample();
            sample.setId(sampleId);
            sample.setAnnotations(new HashMap<>());
            samples.add(sample);

            org.opencb.biodata.models.metadata.Individual individual = new org.opencb.biodata.models.metadata.Individual();
            individual.setId(sampleId);
            individual.setSamples(samples);

            variantStudyMetadata.getIndividuals().add(individual);
        }


        variantStudyMetadata.getFiles().add(fileMetadata);
    }
1174334
def setup(app):
    

    app.add_config_value("cache_path", "_cache", "")

    try:
        os.makedirs(app.config.cache_path)
    except OSError as error:
        if error.errno != errno.EEXIST:
            raise

    path = os.path.join(app.config.cache_path, "spec.html")
    spec = fetch_or_load(path)
    app.add_role("validator", docutils_sucks(spec))
1185114
def add_note(path, filename="note.txt"):
    
    path = os.path.expanduser(path)
    assert os.path.isdir(path), "{} is not a valid directory.".format(path)

    filepath = os.path.join(path, filename)
    exists = os.path.isfile(filepath)

    try:
        subprocess.call([EDITOR, filepath])
    except Exception as exc:
        logger.error("Editing note failed!")
        raise exc
    if exists:
        print("Note updated at:", filepath)
    else:
        print("Note created at:", filepath)
279933
public static void addFileToClassPath(Path file, Configuration conf)
    throws IOException {
    String classpath = conf.get("mapred.job.classpath.files");
    conf.set("mapred.job.classpath.files", classpath == null ? file.toString()
             : classpath + System.getProperty("path.separator") + file.toString());
    URI uri = file.makeQualified(file.getFileSystem(conf)).toUri();

    addCacheFile(uri, conf);
  }
533623
def build_specfile_sections(spec):
    
    str = ""

    mandatory_sections = {
        'DESCRIPTION'  : '\n%%description\n%s\n\n', }

    str = str + SimpleTagCompiler(mandatory_sections).compile( spec )

    optional_sections = {
        'DESCRIPTION_'        : '%%description -l %s\n%s\n\n',
        'CHANGELOG'           : '%%changelog\n%s\n\n',
        'X_RPM_PREINSTALL'    : '%%pre\n%s\n\n',
        'X_RPM_POSTINSTALL'   : '%%post\n%s\n\n',
        'X_RPM_PREUNINSTALL'  : '%%preun\n%s\n\n',
        'X_RPM_POSTUNINSTALL' : '%%postun\n%s\n\n',
        'X_RPM_VERIFY'        : '%%verify\n%s\n\n',

        # These are for internal use but could possibly be overridden
        'X_RPM_PREP'          : '%%prep\n%s\n\n',
        'X_RPM_BUILD'         : '%%build\n%s\n\n',
        'X_RPM_INSTALL'       : '%%install\n%s\n\n',
        'X_RPM_CLEAN'         : '%%clean\n%s\n\n',
        }

    # Default prep, build, install and clean rules
    # TODO: optimize those build steps, to not compile the project a second time
    if 'X_RPM_PREP' not in spec:
        spec['X_RPM_PREP'] = '[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf "$RPM_BUILD_ROOT"' + '\n%setup -q'

    if 'X_RPM_BUILD' not in spec:
        spec['X_RPM_BUILD'] = '[ ! -e "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && mkdir "$RPM_BUILD_ROOT"'

    if 'X_RPM_INSTALL' not in spec:
        spec['X_RPM_INSTALL'] = 'scons --install-sandbox="$RPM_BUILD_ROOT" "$RPM_BUILD_ROOT"'

    if 'X_RPM_CLEAN' not in spec:
        spec['X_RPM_CLEAN'] = '[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf "$RPM_BUILD_ROOT"'

    str = str + SimpleTagCompiler(optional_sections, mandatory=0).compile( spec )

    return str