Get file priority rules.
497561
def get_priority_rules(db) -> Iterable[PriorityRule]:
    """"""
    cur = db.cursor()
    cur.execute('SELECT id, regexp, priority FROM file_priority')
    for row in cur:
        yield PriorityRule(*row)
226220
def get_loaded_rules(rules_paths):
    
    for path in rules_paths:
        if path.name != '__init__.py':
            rule = Rule.from_path(path)
            if rule.is_enabled:
                yield rule
862094
def set_file_priority(self, infohash, file_id, priority):
        
        if priority not in [0, 1, 2, 7]:
            raise ValueError("Invalid priority, refer WEB-UI docs for info.")
        elif not isinstance(file_id, int):
            raise TypeError("File ID must be an int")

        data = {'hash': infohash.lower(),
                'id': file_id,
                'priority': priority}

        return self._post('command/setFilePrio', data=data)
787739
public function rules()
    {
        return [
            'file' => [
                'bail',
                'required',
                'file',
                // imagealphablending or imagesavealpha == 500 error
                ('image' == $this->input('type')) ? 'dimensions:max_width=3840,max_height=2400' : '',
            ],

            'user_id' => [
                'required',
                'integer',
                'in:'.$this->user()->id,
            ],
            // Always check the `attachment_type` first.
            'attachment_type' => [
                'nullable',
                'alpha_dash',
                'in:'.self::morphMap(),
            ],
            // After that, we check for a record in the database.
            'attachment_id' => [
                'bail',
                'nullable',
                'integer',
                'required_with:attachment_type',
                'exists:'.$this->input('attachment_type').',id',
            ],
            'disk' => [
                'required',
                'in:'.implode(',', array_keys(config('filesystems.disks'))),
            ],
            'category' => [
                'required',
                'string','alpha_dash',
            ],

            // Unstable data.
            'type' => [
                'required',
            ],
            'mime_type' => [
                'required',
                'string',
            ],
            'name' => [
                'required',
                'string',
                'alpha_dash',
            ],
            'extension' => [
                'required',
                'string',
            ],
            'filesize' => [
                'required',
                'integer',
            ],
            'checksum' => [
                'required',
                'alpha_num',
                // Check below, we need links to the file.
                // 'unique:files'
            ],

            'title' => [
                'required',
                'string',
                'max:255',
                'regex:/^[\w\s\.\,\-\_\?\!\(\)\[\]]+$/u',
            ],
            'description' => [
                'nullable',
                'string',
                'max:1000',
            ],
            'properties' =>  [
                'nullable',
                'array',
            ],
        ];
    }
142115
def getabsfile(object):
    """"""
    return os.path.normcase(
        os.path.abspath(getsourcefile(object) or getfile(object)))
149512
def get_paths(folder):
    ''''''
    folder = pathlib.Path(folder).resolve()
    files = folder.rglob("*_phase.txt")
    return sorted(files)
770420
def qualified_files(self, absolute=True):
        """"""
        prefix = self.get_directory() if absolute else "."
        for rel_dir_name, file_name in self.files():
            yield os.path.join(prefix, rel_dir_name, file_name)
584120
private function _files_pref(){
    if ( !self::$files_pref ){
      if ( $id = $this->options->from_code(self::FILES_PREF, self::IDE_PATH) ){
        self::set_files_pref($id);
      }
    }
    return self::$files_pref;
  }
240063
def get_priority(self) -> int:
        
        dtype = self.get_type()
        if dtype & DeltaType.PRE:
            return 1
        elif dtype & DeltaType.POST:
            return 3
        else:
            return 2
1310165
def __get_delta_files(self):
        """"""
        files = [(d, f) for d in self.dirs for f in listdir(d) if isfile(join(d, f))]

        deltas = OrderedDict()
        for d, f in files:
            file_ = join(d, f)

            if not Delta.is_valid_delta_name(file_):
                continue

            delta = Delta(file_)

            if d not in deltas:
                deltas[d] = []
            deltas[d].append(delta)

        # sort delta objects in each bucket
        for d in deltas:
            deltas[d].sort(key=lambda x: (x.get_version(), x.get_priority(), x.get_name()))

        return deltas
268851
public Priority[] filePriorities() {
        int_vector v = th.get_file_priorities2();
        int size = (int) v.size();
        Priority[] arr = new Priority[size];
        for (int i = 0; i < size; i++) {
            arr[i] = Priority.fromSwig(v.get(i));
        }
        return arr;
    }
108017
public List<String> getRuleFileNames() {
    List<String> ruleFiles = new ArrayList<>();
    ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
    ruleFiles.add(dataBroker.getRulesDir()
            + "/" + getShortCode() + "/" + JLanguageTool.PATTERN_FILE);
    if (getShortCodeWithCountryAndVariant().length() > 2) {
      String fileName = getShortCode() + "/"
              + getShortCodeWithCountryAndVariant()
              + "/" + JLanguageTool.PATTERN_FILE;
      if (dataBroker.ruleFileExists(fileName)) {
        ruleFiles.add(dataBroker.getRulesDir() + "/" + fileName);
      }
    }
    return ruleFiles;
  }
578166
def get_ordering(self):
        """"""
        if self.sorting_field:
            return [self.sorting_field]
        prefix = self.get_prefix()
        fields = self.get_ordering_with_prefix()
        if self.prefix:
            fields = [f.replace(prefix, "", 1) for f in fields]
        return [
            f
            for f in fields
            if f.lstrip("-") in self.get_ordering_fields_lookups()
        ]
145620
protected function getIncomingFiles()
    {
        $fh = $this->app->make('helper/validation/file');
        $nh = $this->app->make('helper/number');
        $incoming = $this->app->make(Incoming::class);
        $files = $incoming->getIncomingFilesystem()->listContents($incoming->getIncomingPath());
        foreach (array_keys($files) as $index) {
            $files[$index]['allowed'] = $fh->extension($files[$index]['basename']);
            $files[$index]['thumbnail'] = FileTypeList::getType($files[$index]['extension'])->getThumbnail();
            $files[$index]['displaySize'] = $nh->formatSize($files[$index]['size'], 'KB');
        }

        return $files;
    }
443174
def get_migration_files(self):
        """"""
        migrations = (re.match(MigrationFile.PATTERN, filename)
                      for filename in os.listdir(self.directory))
        migrations = (MigrationFile(m.group('id'), m.group(0))
                      for m in migrations if m)
        return sorted(migrations, key=lambda m: m.id)
1017700
function checkRequiredFiles(files) {
  try {
    files.forEach(filePath => {
      fs.accessSync(filePath, fs.F_OK);
    });
    return true;
  } catch (err) {
    return false;
  }
}
1204034
def get_rulesets():
    "
    rulesets_dirs = get_ruleset_dirs()
    ruleset_files = []
    for rulesets_dir in rulesets_dirs:
        for f in os.listdir(rulesets_dir):
            for ext in EXTS:
                file_path = os.path.join(rulesets_dir, f)
                if os.path.isfile(file_path) and f.lower().endswith(ext):
                    ruleset_files.append((f[:-len(ext)], file_path))
    return ruleset_files