Test Failed
Push — master ( 8192fe...83ef1f )
by Steffen
02:25
created

run_application()   A

Complexity

Conditions 3

Size

Total Lines 48

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
cc 3
c 3
b 0
f 2
dl 0
loc 48
rs 9.125
1
#!/usr/bin/python
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
# -*- coding: utf-8 -*-
3
import argparse
4
import logging
5
6
from saucenao.files.constraint import Constraint
7
from saucenao.files.filehandler import FileHandler
8
from saucenao.files.filter import Filter
9
from saucenao.saucenao import SauceNao
10
from saucenao.worker import Worker
11
12
__all__ = [SauceNao, FileHandler, Filter, Constraint]
0 ignored issues
show
introduced by
Invalid object 'SauceNao' in __all__, must contain only strings
Loading history...
introduced by
Invalid object 'FileHandler' in __all__, must contain only strings
Loading history...
introduced by
Invalid object 'Filter' in __all__, must contain only strings
Loading history...
introduced by
Invalid object 'Constraint' in __all__, must contain only strings
Loading history...
13
14
15
def run_application():
16
    """Run SauceNao based on arguments passed to the file
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
17
18
    :return:
19
    """
20
    parser = argparse.ArgumentParser()
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
21
    parser.add_argument('-d', '--dir', help='directory to sort', required=True)
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
22
    parser.add_argument('-db', '--databases', default=999, type=int, help='which databases should be searched')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (111/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
23
    parser.add_argument('-min', '--minimum-similarity', default=65, type=float,
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
24
                        help='minimum similarity percentage')
25
    parser.add_argument('-c', '--combine-api-types', action='store_true',
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
26
                        help='combine html and json api response to retrieve more information')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (95/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
27
    parser.add_argument('-k', '--api-key', help='API key of your account on SauceNao')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (86/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
28
    parser.add_argument('-x', '--exclude-categories', type=str, help='exclude specific categories from moving')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (111/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
29
    parser.add_argument('-mv', '--move-to-categories', action='store_true', help='move images to categories')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (109/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
30
    parser.add_argument('-o', '--output-type', default=0, type=int, help='0(html) or 2(json) API response')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (107/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
31
    parser.add_argument('-sf', '--start-file',
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
32
                        help='with which file the checks start in case of after reaching the daily limit')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (106/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
33
    parser.add_argument('-log', '--log-level', default=logging.ERROR, type=int,
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
34
                        help='which log level should be used, check logging._levelNames for options')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (101/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
35
36
    parser.add_argument('-fcrdt', '--filter-creation-date', type=str,
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
37
                        help='filters files for created after given date. '
38
                             'Format of date has to match "d.m.Y[ H:M[:S]]"')
39
    parser.add_argument('-fmdt', '--filter-modified-date', type=str,
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
40
                        help='filters files for modified after given date. '
41
                             'Format of date has to match "d.m.Y[ H:M[:S]]"')
42
43
    parser.add_argument('-tmin', '--title-minimum-similarity', default=95, type=float,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (86/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
44
                        help='minimum similarity percentage for title search with BakaUpdates')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (95/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
45
46
    args = parser.parse_args()
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
47
48
    file_filter = Filter(assert_is_file=True)
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
49
    if args.filter_creation_date:
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
50
        file_filter.filter_creation_date = Constraint(value=args.filter_creation_date,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (86/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
51
                                                      cmp_func=Constraint.cmp_value_bigger_or_equal)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (100/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
52
    if args.filter_modified_date:
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
53
        file_filter.filter_modified_date = Constraint(value=args.filter_modified_date,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (86/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
54
                                                      cmp_func=Constraint.cmp_value_bigger_or_equal)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (100/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
55
    files = FileHandler.get_files(args.dir, file_filter)
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
56
57
    saucenao_worker = Worker(files=files, directory=args.dir, databases=args.databases,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (87/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
58
                             minimum_similarity=args.minimum_similarity, combine_api_types=args.combine_api_types,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (114/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
59
                             api_key=args.api_key, exclude_categories=args.exclude_categories,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (94/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
60
                             move_to_categories=args.move_to_categories, start_file=args.start_file,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (100/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
61
                             log_level=args.log_level, title_minimum_similarity=args.title_minimum_similarity)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (110/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
62
    return saucenao_worker.run()
0 ignored issues
show
Coding Style introduced by
Found indentation with spaces instead of tabs
Loading history...
63