load a version 2 control file
322315
def _load_version2(self,filename):
        
        self.lcount  = 0
        self.comments = {}
        self.prior_information = self.null_prior
        assert os.path.exists(filename), "couldn't find control file {0}".format(filename)
        f = open(filename, 'r')
        last_section = ""
        req_sections = {"* parameter data":False, "* observation data":False,
                        "* model command line":False,"* model input":False, "* model output":False}
        while True:

            next_section, section_lines, comments = self._read_section_comments(f, True)


            if "* control data" in last_section.lower():
                req_sections[last_section] = True
                iskeyword = False
                if "keyword" in last_section.lower():
                    iskeyword = True
                self.pestpp_options = self.control_data.parse_values_from_lines(section_lines, iskeyword=iskeyword)
                if len(self.pestpp_options) > 0:
                    ppo = self.pestpp_options
                    svd_opts = ["svdmode","eigthresh","maxsing","eigwrite"]
                    for svd_opt in svd_opts:
                        if svd_opt in ppo:
                            self.svd_data.__setattr__(svd_opt, ppo.pop(svd_opt))
                    for reg_opt in self.reg_data.should_write:
                        if reg_opt in ppo:
                            self.reg_data.__setattr__(reg_opt, ppo.pop(reg_opt))

            elif "* parameter groups" in last_section.lower():
                req_sections[last_section] = True
                self.parameter_groups = self._cast_df_from_lines(next_section, section_lines, self.pargp_fieldnames,
                                                                self.pargp_converters, self.pargp_defaults)
                self.parameter_groups.index = self.parameter_groups.pargpnme

            elif "* parameter data" in last_section.lower():
                req_sections[last_section] = True
                self.parameter_data = self._cast_df_from_lines(next_section, section_lines, self.par_fieldnames,
                                                               self.par_converters, self.par_defaults)
                self.parameter_data.index = self.parameter_data.parnme

            elif "* observation data" in last_section.lower():
                req_sections[last_section] = True
                self.observation_data = self._cast_df_from_lines(next_section, section_lines, self.obs_fieldnames,
                                                                self.obs_converters, self.obs_defaults)
                self.observation_data.index = self.observation_data.obsnme

            elif "* model command line" in last_section.lower():
                req_sections[last_section] = True
                for line in section_lines:
                    self.model_command.append(line.strip())

            elif "* model input" in last_section.lower():
                req_sections[last_section] = True
                if section_lines[0].strip().split()[0].lower() == "external":
                    filename = section_lines[0].strip().split()[1]
                    assert os.path.exists(filename),"Pst.flex_load() external template data file '{0}' not found".format(filename)
                    df = pd.read_csv(filename)
                    df.columns = df.columns.str.lower()
                    assert "pest_file" in df.columns,"Pst.flex_load() external template data file must have 'pest_file' in columns"
                    assert "model_file" in df.columns, "Pst.flex_load() external template data file must have 'model_file' in columns"
                    for pfile,mfile in zip(df.pest_file,df.model_file):
                        self.template_files.append(pfile)
                        self.input_files.append(mfile)

                else:
                    for iline,line in enumerate(section_lines):
                        raw = line.split()
                        self.template_files.append(raw[0])
                        self.input_files.append(raw[1])

            elif "* model output" in last_section.lower():
                req_sections[last_section] = True
                if section_lines[0].strip().split()[0].lower() == "external":
                    filename = section_lines[0].strip().split()[1]
                    assert os.path.exists(filename), "Pst.flex_load() external instruction data file '{0}' not found".format(
                        filename)
                    df = pd.read_csv(filename)
                    df.columns = df.columns.str.lower()
                    assert "pest_file" in df.columns, "Pst.flex_load() external instruction data file must have 'pest_file' in columns"
                    assert "model_file" in df.columns, "Pst.flex_load() external instruction data file must have 'model_file' in columns"
                    for pfile, mfile in zip(df.pest_file, df.model_file):
                        self.instruction_files.append(pfile)
                        self.output_files.append(mfile)
                else:
                    for iline, line in enumerate(section_lines):
                        raw = line.split()
                        self.instruction_files.append(raw[0])
                        self.output_files.append(raw[1])

            elif "* prior information" in last_section.lower():
                req_sections[last_section] = True
                self._cast_prior_df_from_lines(section_lines)

            elif len(last_section) > 0:
                print("Pst._load_version2() warning: unrecognized section: ", last_section)
                self.comments[last_section] = section_lines

            last_section = next_section
            if next_section == None or len(section_lines) == 0:
                break

        not_found = []
        for section,found in req_sections.items():
            if not found:
                not_found.append(section)
        if len(not_found) > 0:
            raise Exception("Pst._load_version2() error: the following required sections were"+\
                    "not found:{0}".format(",".join(not_found)))
875787
def load_template(name, directory, extension, encoding, encoding_errors):
    
    abs_path = get_abs_template_path(name, directory, extension)
    return load_file(abs_path, encoding, encoding_errors)
1283962
def get_version(path = Dir.pwd, options = {})
      rootdir = normalized_path(path)
      version = (options[:default]) ? options[:default] : FalkorLib.config[:versioning][:default]
      type    = (options[:type])    ? options[:type]    : FalkorLib.config[:versioning][:type]
      source  = (options[:source])  ? options[:source]  : FalkorLib.config[:versioning][:source][ type ]
      puts "type = '#{type}'"
      case type
      when 'file'
        versionfile = File.join( rootdir, source[:filename] )
        puts "versionfile = '#{versionfile}'"
        version = File.read( versionfile ).chomp if File.exist?( versionfile )
      when 'gem'
        getmethod = source[:getmethod ]
        version = eval( getmethod ) unless (getmethod.nil? || getmethod.empty?)
      when 'puppet_module'
        jsonfile = File.join( rootdir, source[:filename] )
        metadata = JSON.parse( IO.read( jsonfile ) )
        version  = metadata["version"]
      end
      version
    end
1220505
def load_file_ui(self):
        

        editor = self.get_current_editor()
        file = editor and editor.file or None

        browsedPath = os.path.dirname(file) if foundations.common.path_exists(
            file) else RuntimeGlobals.last_browsed_path
        files = umbra.ui.common.store_last_browsed_path(QFileDialog.getOpenFileNames(self,
                                                                                     "Load File(s):",
                                                                                     browsedPath,
                                                                                     self.__get_supported_file_types_string()))
        if not files:
            return False

        success = True
        for file in files:
            success *= self.load_file(file)
        return success
19281
def require_compatible_version(compatible_version, word="File"):
    """"""
    if isinstance(compatible_version, str):
        compatible_version = parse_version(compatible_version)
    elif not isinstance(compatible_version, Version):
        raise ValueError("Type of `compatible_version` not understood.")
    
    current_version = parse_version(CURRENT_VERSION)
    if current_version < compatible_version:
        raise VersionError("{0} written for version >= {1}, this is {2}.".format(
            word, str(compatible_version), CURRENT_VERSION
        ))
300106
void readControlFile(String fileName) throws IOException {
		BufferedReader reader = new BufferedReader(new FileReader(fileName));
		try {
			controlList.clear();

			String line;
			while ((line = reader.readLine()) != null) {
				line = line.trim();

				if (line.isEmpty() || line.startsWith("#")) {
					continue;
				}

				int separatorIndex = line.indexOf('=');

				if (separatorIndex <= 0) {
					logger.warn("Control file line \"" + line + "\" is invalid as does not have '=' separator.");
					continue;
				}

				String className = line.substring(0, separatorIndex);
				ControlMode controlMode;
				try {
					controlMode = ControlMode.valueOf(line.substring(separatorIndex + 1).trim().toUpperCase());
				}
				catch (IllegalArgumentException e) {
					logger.warn("Control file line \"" + line + "\" is invalid as control mode is unknown.");
					continue;
				}

				controlList.add(new ControlEntry(
				            className.startsWith("/") && className.endsWith("/") && className.length() > 2
				                        ? Pattern.compile(className.substring(1, className.length() - 1))
				                        : Pattern.compile(className, Pattern.LITERAL),
				            controlMode));
			}
			configurationValues.put(ConfigurationOption.CONTROL, fileName);
		}
		finally {
			reader.close();
		}
	}
941252
def load_file(self, filename):
        """"""

        self.counter.clear()
        # python2 issues
        try:
            etree = ET.parse(filename)
        except ET.ParseError:
            parser = ET.XMLParser(encoding='UTF-8')
            etree = ET.parse(filename, parser)
        eroot = etree.getroot()

        self.remove_all()
        self.previewer.remove_all()
        self.widget_editor.hide_all()

        self.previewer.resource_paths.append(os.path.dirname(filename))
        for element in eroot:
            self.populate_tree('', eroot, element,from_file=True)
        children = self.treeview.get_children('')
        for child in children:
            self.draw_widget(child)
        self.previewer.show_selected(None, None)
834686
def get_cli():
    """"""
    parser = argparse.ArgumentParser(
        prog="auto_version",
        description="auto version v%s: a tool to control version numbers" % __version__,
    )
    parser.add_argument(
        "--target",
        action="append",
        default=[],
        help="Files containing version info. "
        "Assumes unique variable names between files. (default: %s)."
        % (config.targets,),
    )
    parser.add_argument(
        "--bump",
        choices=SemVerSigFig,
        help="Bumps the specified part of SemVer string. "
        "Use this locally to correctly modify the version file.",
    )
    parser.add_argument(
        "--news",
        "--file-triggers",
        action="store_true",
        dest="file_triggers",
        help="Detects need to bump based on presence of files (as specified in config).",
    )
    parser.add_argument(
        "--set",
        help="Set the SemVer string. Use this locally to set the project version explicitly.",
    )
    parser.add_argument(
        "--set-patch-count",
        action="store_true",
        help="Sets the patch number to the commit count.",
    )
    parser.add_argument(
        "--lock",
        action="store_true",
        help="Locks the SemVer string. "
        "Lock will remain for another call to autoversion before being cleared.",
    )
    parser.add_argument(
        "--release",
        action="store_true",
        default=False,
        help="Marks as a release build, which flags the build as released.",
    )
    parser.add_argument(
        "--version",
        action="store_true",
        default=False,
        help="Prints the version of auto_version itself (self-version).",
    )
    parser.add_argument("--config", help="Configuration file path.")
    parser.add_argument(
        "-v",
        "--verbosity",
        action="count",
        default=0,
        help="increase output verbosity. " "can be specified multiple times",
    )
    return parser.parse_known_args()
1157290
def get_version(file_name='beautysh/__init__.py'):
    """"""
    with open(file_name) as v_file:
        for line in v_file:
            if "__version__" in line:
                return eval(line.split('=')[-1])
573563
def stored_version(self, name):
        """"""
        link_path = self._link_path(name)
        if not _path_exists(link_path):
            return None
        return _file_version(link_path)
906041
def _get_file_version(self, infile):
        """"""

        # Determine file version
        for line1 in infile:
            if line1.strip() != "[Pyspread save file version]":
                raise ValueError(_("File format unsupported."))
            break

        for line2 in infile:
            return line2.strip()
482330
def read_version():
    ""
    version_file = local_file('source', 'added_value', 'version.py')
    local_vars = {}
    with open(version_file) as handle:
        exec(handle.read(), {}, local_vars)  # pylint: disable=exec-used
    return local_vars['__version__']
1250635
def _load(content_or_fp):
    
    try:
        data = yaml.load(content_or_fp, Loader=yaml.loader.BaseLoader)
    except Exception as e:
        raise type(e)('Malformed yaml file:\n%r' % format_exc())

    try:
        ver = data['spec']
    except:
        raise ValueError('The file does not specify a spec version')

    try:
        ver = tuple(map(int, (ver.split("."))))
    except:
        raise ValueError("Invalid spec version format. Expect 'X.Y'"
                         " (X and Y integers), found %s" % ver)

    if ver > SPEC_VERSION_TUPLE:
        raise ValueError('The spec version of the file is '
                         '%s but the parser is %s. '
                         'Please update pyvisa-sim.' % (ver, SPEC_VERSION))

    return data
662806
def _load(self):
        """"""
        if os.path.exists(self.path):
            root = ET.parse(self.path).getroot()
            if (root.tag == "fortpy" and "mode" in root.attrib and
                root.attrib["mode"] == "template" and "direction" in root.attrib and
                root.attrib["direction"] == self.direction):
                #First, we need instances of the template contents for each of the
                #versions listed in the fortpy tag.
                for v in _get_xml_version(root):
                    self.versions[v] = TemplateContents()
                #Now we can update the contents objects using the XML data.
                self._load_entries(root)

                #See if a custom name was specified for the auto-converted
                #files.
                if "autoname" in root.attrib:
                    self.name = root.attrib["autoname"]
            else:
                msg.err("the specified template {} ".format(self.path) + 
                        "is missing the mode and direction attributes.")
                exit(1)
        else:
            msg.err("could not find the template {}.".format(self.path))
            exit(1)
74711
def read_release_version():
    """"""
    import re
    dirname = os.path.abspath(os.path.dirname(__file__))

    try:
        f = open(os.path.join(dirname, "_version.py"), "rt")
        for line in f.readlines():

            m = re.match("__version__ = '([^']+)'", line)
            if m:
                ver = m.group(1)
                return ver

    except:
        return None

    return None
1282306
private void load() {
        URL url = UIVersion.class.getResource("version.properties"); //$NON-NLS-1$
        if (url == null) {
            this.versionString = "Unknown"; //$NON-NLS-1$
            this.versionDate = new Date().toString();
        } else {
            InputStream is = null;
            Properties props = new Properties();
            try {
                is = url.openStream();
                props.load(is);
                this.versionString = props.getProperty("version", "Unknown"); //$NON-NLS-1$ //$NON-NLS-2$
                this.versionDate = props.getProperty("date", new Date().toString()); //$NON-NLS-1$
            } catch (IOException e) {
                throw new RuntimeException(e);
            } finally {
                IOUtils.closeQuietly(is);
            }
        }
    }
176154
def load(self, name, skip='', skip_original='', default_template=None, layout=None):
        """"""
        filename = self.resolve_path(name, skip=skip, skip_original=skip_original,
                                     default_template=default_template)

        if not filename:
            raise ParseError("Can't find template %s." % name)

        with self.lock:
            if layout:
                _filename = filename + '$$' + layout
                mtime = os.path.getmtime(filename)
            else:
                mtime = None
                _filename = filename

            if self.cache:
                if not self.use_tmp:
                    #check current template file expiration
                    t = self.templates.get(_filename, mtime=mtime)
                    if t:
                        #check depends tempaltes expiration
                        check = self.check_expiration(t)
                        if not check:
                            return t
                else:
                    #get cached file from disk
                    pass
            t = self._create_template(name, filename, layout=layout)
            if self.cache:
                if not self.use_tmp:
                    self.templates.set(_filename, t, mtime)
                else:
                    #save cached file to disk
                    pass

            return t