Populate table with files from scenario_directory directory.

        :param scenario_directory: Path where .txt & .py reside.
        :type scenario_directory: QString
511512
def populate_table(self, scenario_directory):
        
        parsed_files = []
        unparsed_files = []
        self.table.clearContents()

        # Block signal to allow update checking only when the table is ready
        self.table.blockSignals(True)
        # NOTE(gigih): need this line to remove existing rows
        self.table.setRowCount(0)

        if not os.path.exists(scenario_directory):
            # LOGGER.info('Scenario directory does not exist: %s' % path)
            return

        # only support .py and .txt files
        for current_path in os.listdir(scenario_directory):
            extension = os.path.splitext(current_path)[1]
            absolute_path = os.path.join(scenario_directory, current_path)

            if extension == '.py':
                append_row(self.table, current_path, absolute_path)
            elif extension == '.txt':
                # insert scenarios from file into table widget
                try:
                    scenarios = read_scenarios(absolute_path)
                    validate_scenario(scenarios, scenario_directory)
                    for key, value in list(scenarios.items()):
                        append_row(self.table, key, value)
                    parsed_files.append(current_path)
                except Error:
                    unparsed_files.append(current_path)

        # unblock signal
        self.table.blockSignals(False)
273277
def populateFromDirectory(self, vcfDirectory):
        
        pattern = os.path.join(vcfDirectory, "*.vcf.gz")
        dataFiles = []
        indexFiles = []
        for vcfFile in glob.glob(pattern):
            dataFiles.append(vcfFile)
            indexFiles.append(vcfFile + ".tbi")
        self.populateFromFile(dataFiles, indexFiles)
930534
def step_a_new_working_directory(context):
    
    command_util.ensure_context_attribute_exists(context, "workdir", None)
    command_util.ensure_workdir_exists(context)
    shutil.rmtree(context.workdir, ignore_errors=True)
902277
def populate():
    
    os.chdir("Misc")
    safe_mkdir("NEWS.d/next")

    for section in sections:
        dir_name = sanitize_section(section)
        dir_path = f("NEWS.d/next/{dir_name}")
        safe_mkdir(dir_path)
        readme_path = f("NEWS.d/next/{dir_name}/README.rst")
        with open(readme_path, "wt", encoding="utf-8") as readme:
            readme.write(f("Put news entry ``blurb`` files for the *{section}* section in this directory.\n"))
        git_add_files.append(dir_path)
        git_add_files.append(readme_path)
    flush_git_add_files()
242954
def create(ctx, scenario_name, driver_name):  # pragma: no cover
    
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
        'driver_name': driver_name,
    }

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
407615
def copy_data_from_scenario(resource_attrs, source_scenario_id, target_scenario_id, **kwargs):
    

    #Get all the resource scenarios we wish to update
    target_resourcescenarios = db.DBSession.query(ResourceScenario).filter(
            ResourceScenario.scenario_id==target_scenario_id,
            ResourceScenario.resource_attr_id.in_(resource_attrs)).all()

    target_rs_dict = {}
    for target_rs in target_resourcescenarios:
        target_rs_dict[target_rs.resource_attr_id] = target_rs

    #get all the resource scenarios we are using to get our datsets source.
    source_resourcescenarios = db.DBSession.query(ResourceScenario).filter(
            ResourceScenario.scenario_id==source_scenario_id,
            ResourceScenario.resource_attr_id.in_(resource_attrs)).all()

    #If there is an RS in scenario 'source' but not in 'target', then create
    #a new one in 'target'
    for source_rs in source_resourcescenarios:
        target_rs = target_rs_dict.get(source_rs.resource_attr_id)
        if target_rs is not None:
            target_rs.dataset_id = source_rs.dataset_id
        else:
            target_rs = ResourceScenario()
            target_rs.scenario_id      = target_scenario_id
            target_rs.dataset_id       = source_rs.dataset_id
            target_rs.resource_attr_id = source_rs.resource_attr_id
            db.DBSession.add(target_rs)

    db.DBSession.flush()

    return target_resourcescenarios
361395
def _from_directory(self, dirname, prefix=""):
        
        ps = [os.path.join(here, dirname, p) for p in os.listdir(os.path.join(here, dirname))]
        n = prefix + wt_kit.string2identifier(os.path.basename(dirname))
        setattr(self, n, ps)
686693
def __add_location(self, type, *args):
        

        if type == "directory":
            location = umbra.ui.common.store_last_browsed_path((QFileDialog.getExistingDirectory(self,
                                                                                                 "Add Directory:",
                                                                                                 RuntimeGlobals.last_browsed_path)))
        elif type == "file":
            location = umbra.ui.common.store_last_browsed_path((QFileDialog.getOpenFileName(self,
                                                                                            "Add File:",
                                                                                            RuntimeGlobals.last_browsed_path,
                                                                                            "All Files (*)")))
        elif type == "editors":
            location = self.__targets_format.format(self.__default_target)
        elif type == "include_filter":
            location = self.__filters_in_format.format(self.__default_filter_in)
        elif type == "exclude_filter":
            location = self.__filters_out_format.format(self.__default_filter_out)

        location and self.Where_lineEdit.setText(", ".join(filter(bool, (foundations.strings.to_string(
            self.Where_lineEdit.text()), location))))
1356212
def before_scenario(context, scenario):
    """"""

    # Prepare a new temporary directory.
    context.directory = testfixtures.TempDirectory(create=True)
    context.old_cwd = os.getcwd()
    context.new_cwd = context.directory.path

    # Move into our new working directory.
    os.chdir(context.new_cwd)
477066
def add_variables_from_directory(self, directory):
        
        py_files = glob.glob(path.join(directory, "*.py"))
        for py_file in py_files:
            self.add_variables_from_file(py_file)
        subdirectories = glob.glob(path.join(directory, "*/"))
        for subdirectory in subdirectories:
            self.add_variables_from_directory(subdirectory)
635379
def load_directory(self, top_path, followlinks):
        
        for dir_name, child_dirs, child_files in os.walk(top_path, followlinks=followlinks):
            for child_filename in child_files:
                if child_filename == DDS_IGNORE_FILENAME:
                    pattern_lines = self._read_non_empty_lines(dir_name, child_filename)
                    self.add_patterns(dir_name, pattern_lines)
1202099
def load_messages(self, directory, catalogue):
        
        if not os.path.isdir(directory):
            raise ValueError("{0} is not a directory".format(directory))

        for format, loader in list(self.loaders.items()):
            extension = "{0}.{1}".format(catalogue.locale, format)
            files = find_files(directory, "*.{0}".format(extension))
            for file in files:
                domain = file.split("/")[-1][:-1 * len(extension) - 1]
                catalogue.add_catalogue(
                    loader.load(
                        file,
                        catalogue.locale,
                        domain))
547757
def create_tomodir(self, directory):
        
        pwd = os.getcwd()
        if not os.path.isdir(directory):
            os.makedirs(directory)
        os.chdir(directory)

        directories = (
            'config',
            'exe',
            'grid',
            'mod',
            'mod/pot',
            'mod/sens',
            'rho',
        )
        for directory in directories:
            if not os.path.isdir(directory):
                os.makedirs(directory)

        os.chdir(pwd)
1101236
def choose_file_or_dir():
    
    question = QMessageBox(QMessageBox.Information, 'Open Dataset',
                           'Do you want to open a file or a directory?')
    dir_button = question.addButton('Directory', QMessageBox.YesRole)
    file_button = question.addButton('File', QMessageBox.NoRole)
    question.addButton(QMessageBox.Cancel)
    question.exec_()
    response = question.clickedButton()

    if response == dir_button:
        return 'dir'
    elif response == file_button:
        return 'file'
    else:
        return 'abort'
501280
def setup_driver(scenario):
    
    if not hasattr(world, 'config_files'):
        world.config_files = ConfigFiles()

    # By default config directory is located in terrain path
    if not world.config_files.config_directory:
        world.config_files.set_config_directory(DriverWrappersPool.get_default_config_directory())

    world.global_status = {'test_passed': True}
    bdd_common_before_scenario(world, scenario)
14448
def prepare_data_maybe_download(directory):
    
    filename = 'ubuntu_dialogs.tgz'
    url = 'http://cs.mcgill.ca/~jpineau/datasets/ubuntu-corpus-1.0/ubuntu_dialogs.tgz'
    dialogs_path = os.path.join(directory, 'dialogs')

    # test it there are some dialogs in the path
    if not os.path.exists(os.path.join(directory, "10", "1.tst")):
        # dialogs are missing
        archive_path = os.path.join(directory, filename)
        if not os.path.exists(archive_path):
            # archive missing, download it
            print("Downloading %s to %s" % (url, archive_path))
            filepath, _ = urllib.request.urlretrieve(url, archive_path)
            print "Successfully downloaded " + filepath

        # unpack data
        if not os.path.exists(dialogs_path):
            print("Unpacking dialogs ...")
            with tarfile.open(archive_path) as tar:
                tar.extractall(path=directory)
            print("Archive unpacked.")

        return
1170529
def list_files_in_directory(dir, options)
      files = Dir.glob File.join(dir, "*")

      normalized_file_list options, files, false, options.exclude
    end