Given a DataONE schema, generates a file that contains version information
        about the schema.
355526
def generate_version_file(self, schema_filename, binding_filename):
        """"""
        version_filename = binding_filename + '_version.txt'
        version_path = os.path.join(self.binding_dir, version_filename)
        schema_path = os.path.join(self.schema_dir, schema_filename)
        try:
            tstamp, svnpath, svnrev, version = self.get_version_info_from_svn(
                schema_path
            )
        except TypeError:
            pass
        else:
            self.write_version_file(version_path, tstamp, svnpath, svnrev, version)
537161
def get_version_storage():
    # type: () -> VersionStorage
    
    version_file = conf.get_path('version_file', 'VERSION')
    if version_file.endswith('.py'):
        return PyVersionStorage(version_file)
    elif version_file.endswith('package.json'):
        return NodeVersionStorage(version_file)
    else:
        return RawVersionStorage(version_file)
269232
def get_field_schema(name, field):
    """"""
    field_schema = {
        'type': 'string',
    }

    if field.label:
        field_schema['title'] = str(field.label)  # force translation

    if field.help_text:
        field_schema['description'] = str(field.help_text)  # force translation

    if isinstance(field, (fields.URLField, fields.FileField)):
        field_schema['format'] = 'uri'
    elif isinstance(field, fields.EmailField):
        field_schema['format'] = 'email'
    elif isinstance(field, fields.DateTimeField):
        field_schema['format'] = 'date-time'
    elif isinstance(field, fields.DateField):
        field_schema['format'] = 'date'
    elif isinstance(field, (fields.DecimalField, fields.FloatField)):
        field_schema['type'] = 'number'
    elif isinstance(field, fields.IntegerField):
        field_schema['type'] = 'integer'
    elif isinstance(field, fields.NullBooleanField):
        field_schema['type'] = 'boolean'
    elif isinstance(field.widget, widgets.CheckboxInput):
        field_schema['type'] = 'boolean'

    if getattr(field, 'choices', []):
        field_schema['enum'] = sorted([choice[0] for choice in field.choices])

    # check for multiple values
    if isinstance(field.widget, (widgets.Select, widgets.ChoiceWidget)):
        if field.widget.allow_multiple_selected:
            # promote to array of <type>, move details into the items field
            field_schema['items'] = {
                'type': field_schema['type'],
            }
            if 'enum' in field_schema:
                field_schema['items']['enum'] = field_schema.pop('enum')
            field_schema['type'] = 'array'

    return field_schema
1198097
function _generate(schemaName) {
  var schema = generateSchema(schemaName, this._instructions, this._macros, this._opts.strict);
  this.ajv.removeSchema(schema.id);
  return schema;
}
745610
def get_version_info():
    """"""
    version_info = {}
    with open(os.path.join("refcycle", "version.py"), 'r') as f:
        version_code = compile(f.read(), "version.py", 'exec')
        exec(version_code, version_info)
    return version_info
943179
private void ensureSchemaVersion(Connection conn) throws DatabaseException {
        ResultSet rs = null;
        PreparedStatement ps = null;
        try {
            //TODO convert this to use DatabaseProperties
            ps = conn.prepareStatement("SELECT value FROM properties WHERE id = 'version'");
            rs = ps.executeQuery();
            if (rs.next()) {
                final String dbSchemaVersion = settings.getString(Settings.KEYS.DB_VERSION);
                final DependencyVersion appDbVersion = DependencyVersionUtil.parseVersion(dbSchemaVersion);
                if (appDbVersion == null) {
                    throw new DatabaseException("Invalid application database schema");
                }
                final DependencyVersion db = DependencyVersionUtil.parseVersion(rs.getString(1));
                if (db == null) {
                    throw new DatabaseException("Invalid database schema");
                }
                LOGGER.debug("DC Schema: {}", appDbVersion.toString());
                LOGGER.debug("DB Schema: {}", db.toString());
                if (appDbVersion.compareTo(db) > 0) {
                    updateSchema(conn, appDbVersion, db);
                    if (++callDepth < 10) {
                        ensureSchemaVersion(conn);
                    }
                }
            } else {
                throw new DatabaseException("Database schema is missing");
            }
        } catch (SQLException ex) {
            LOGGER.debug("", ex);
            throw new DatabaseException("Unable to check the database schema version", ex);
        } finally {
            DBUtils.closeResultSet(rs);
            DBUtils.closeStatement(ps);
        }
    }
431774
private Path getOrGenerateSchemaFile(Schema schema) throws IOException {

    Preconditions.checkNotNull(schema, "Avro Schema should not be null");

    String hashedSchema = Hashing.sha256().hashString(schema.toString(), StandardCharsets.UTF_8).toString();

    if (!this.schemaPaths.containsKey(hashedSchema)) {

      Path schemaFilePath = new Path(this.schemaDir, String.valueOf(System.currentTimeMillis() + ".avsc"));
      AvroUtils.writeSchemaToFile(schema, schemaFilePath, fs, true);

      this.schemaPaths.put(hashedSchema, schemaFilePath);
    }

    return this.schemaPaths.get(hashedSchema);
  }
1078219
public void updateSchema(String migrationPath) {
        try {
            logger.info("Updating schema... ");
            int current_version = 0;

            // first check the current schema version
            HashMap<String, Object> configuration = getFirstResult("SELECT * FROM " + Constants.DB_TABLE_CONFIGURATION +
                                                                       " WHERE " + Constants.DB_TABLE_CONFIGURATION_NAME + " = \'" + Constants.DB_TABLE_CONFIGURATION_DATABASE_VERSION + "\'");

            if (configuration == null) {
                logger.info("Creating configuration table..");
                // create configuration table
                executeUpdate("CREATE TABLE "
                                  + Constants.DB_TABLE_CONFIGURATION
                                  + " (" + Constants.GENERIC_ID + " INTEGER IDENTITY,"
                                  + Constants.DB_TABLE_CONFIGURATION_NAME + " VARCHAR(256),"
                                  + Constants.DB_TABLE_CONFIGURATION_VALUE + " VARCHAR(1024));");

                executeUpdate("INSERT INTO " + Constants.DB_TABLE_CONFIGURATION
                                  + "(" + Constants.DB_TABLE_CONFIGURATION_NAME + "," + Constants.DB_TABLE_CONFIGURATION_VALUE + ")"
                                  + " VALUES (\'"
                                  + Constants.DB_TABLE_CONFIGURATION_DATABASE_VERSION
                                  + "\', '0');");
            } else {
                logger.info("Getting current schema version..");
                // get current version
                current_version = new Integer(configuration.get("VALUE").toString());
                logger.info("Current schema version is {}", current_version);
            }

            // loop through until we get up to the right schema version
            while (current_version < Constants.DB_CURRENT_SCHEMA_VERSION) {
                current_version++;

                // look for a schema file for this version
                logger.info("Updating to schema version {}", current_version);
                String currentFile = migrationPath + "/schema."
                    + current_version;
                Resource migFile = new ClassPathResource(currentFile);
                BufferedReader in = new BufferedReader(new InputStreamReader(
                    migFile.getInputStream()));

                String str;
                while ((str = in.readLine()) != null) {
                    // execute each line
                    if (str.length() > 0) {
                        executeUpdate(str);
                    }
                }
                in.close();
            }

            // update the configuration table with the correct version
            executeUpdate("UPDATE " + Constants.DB_TABLE_CONFIGURATION
                              + " SET " + Constants.DB_TABLE_CONFIGURATION_VALUE + "='" + current_version
                              + "' WHERE " + Constants.DB_TABLE_CONFIGURATION_NAME + "='"
                              + Constants.DB_TABLE_CONFIGURATION_DATABASE_VERSION + "';");
        } catch (Exception e) {
            logger.info("Error in executeUpdate");
            e.printStackTrace();
        }
    }
1180395
def get_version_with_beta(version_info: FileVersionResult) -> str:
    

    if not version_info:
        raise TypeError("version_info cannot be 'None'!")

    if not version_info.uniform:
        raise ValueError("version_info is not uniform!")

    # Capture datetime as UTC for build timestamp
    utc_datetime = datetime.datetime.utcnow()

    # Setup version string information
    beta_flag = ".123."
    build_number = utc_datetime.strftime("%Y%m%d.%H%M%S")
    cleaned_version = get_version_without_beta(version_info)

    # Return the new version string for the build.
    return "{base}{flag}{build}".format(
        base=cleaned_version,
        flag=beta_flag,
        build=build_number,
    )
619773
def include_version(global_root: str, version_obj: models.Version, hardlink:bool=True):
    """"""
    global_root_dir = Path(global_root)
    if version_obj.included_at:
        raise VersionIncludedError(f"version included on {version_obj.included_at}")

    # generate root directory
    version_root_dir = global_root_dir / version_obj.relative_root_dir
    version_root_dir.mkdir(parents=True, exist_ok=True)
    log.info(f"created new bundle version dir: {version_root_dir}")

    for file_obj in version_obj.files:
        # hardlink file to the internal structure
        file_obj_path = Path(file_obj.path)
        new_path = version_root_dir / file_obj_path.name
        if hardlink:
            os.link(file_obj_path.resolve(), new_path)
        else:
            os.symlink(file_obj_path.resolve(), new_path)
        log.info(f"linked file: {file_obj.path} -> {new_path}")
        file_obj.path = str(new_path).replace(f"{global_root_dir}/", '', 1)
1125690
def generate_version_file(infile='version.py.in', outfile='version.py', **kwargs):
    

    if not os.path.exists(outfile) and os.path.exists(infile):
        now = datetime.datetime.now()
        repo_hash = ''
        git_path = find_exe('git')
        if git_path is not None:
            git_cmd = [find_exe('git'), 'log', '--format=%h', '-1']
            repo_hash = subprocess.Popen(git_cmd, stdout=subprocess.PIPE).communicate()[0].strip()
        if repo_hash.strip() == '':
            repo_hash = '{now.hour}.{now.minute}.{now.second}'.format(now=now)

        sub_dict = {
            'repo_hash': repo_hash,
            'build_date': '{now.year}.{now.month}.{now.day}'.format(now=now),
            'build_time': '{now.hour}.{now.minute}.{now.second}'.format(now=now),
            'build_host': socket.gethostname(),
            'build_user': getpass.getuser()
        }
        sub_dict.update(**kwargs)

        with open(infile) as version_in:
            version_data = version_in.read()
            version_final = string.Template(version_data).safe_substitute(sub_dict)

        with open(outfile, 'w') as version_out:
            version_out.write(version_final)

    return outfile if os.path.exists(outfile) else None
1151214
function dataPreprocess (version) {
        var util = require('./util');

        if (util.isNumber(version)) {
            version = version.toString();
        }
        if (util.isArray(version)) {
            version = version.join('.');
        }

        if (util.isCorrectVersion(version)) {
            return util.toArray(version);
        }

        return 'Wrong Params.';
    }
681817
function storedFileInformation( $object, $objectVersion, $objectLanguage )
    {
        if ( !$object )
            $object = $this->object();
        if ( $objectVersion === false )
            $objectVersion = $object->attribute( 'current_version' );
        if ( $objectLanguage === false )
            $objectLanguage = $object->attribute( 'default_language' );
        $dataType = $this->dataType();
        return $dataType->storedFileInformation( $object, $objectVersion, $objectLanguage,
                                                 $this );
    }
807587
def update_version_records(self):
        
        from .__init__ import __version__ as version
        with self.connection(commit=True) as connection:
            for vrec in self.get_version_records():
                if (vrec.rash_version == version and
                    vrec.schema_version == schema_version):
                    return  # no need to insert the new one!
            connection.execute(
                'INSERT INTO rash_info (rash_version, schema_version) '
                'VALUES (?, ?)',
                [version, schema_version])
716573
protected function updateSchemaVersionFile() {
    // Write BLT version to blt/.schema-version.
    $latest_update_method_version = $this->updater->getLatestUpdateMethodVersion();
    $schema_file_name = $this->getConfigValue('blt.config-files.schema-version');

    $fs = new Filesystem();
    $fs->dumpFile($schema_file_name, $latest_update_method_version);
  }
1220430
public VersionComparator getSchemaVersion() {
        PreparedStatement statement = null;
        ResultSet results = null;
        try {
            statement = connection.prepareStatement("SELECT \"VERSION\" FROM \"SCHEMAVERSION\"");
            results = statement.executeQuery();

            if (results.next()) {
                return new VersionComparator(results.getString(1));
            }
        } catch (SQLException e) {
            // throw it away
        } finally {
            DbUtil.close(results);
            DbUtil.close(statement);
            //DbUtil.close(connection); // do not close connection
        }
        return null;
    }
630232
@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
  public String getDatabaseSchemaVersion()
  {
    try
    {

      List<Map<String, Object>> result = getJdbcTemplate().
        queryForList(
          "SELECT \"value\" FROM repository_metadata WHERE \"name\"='schema-version'");

      String schema
        = result.size() > 0 ? (String) result.get(0).get("value") : "";
      return schema;
    }
    catch (DataAccessException ex)
    {
      String error = "Wrong database schema (too old to get the exact number), "
        + "please initialize the database.";
      log.error(error);
    }
    return "";
  }