Completed
Push — develop ( 50092f...fea62d )
by Jace
39s queued 35s
created

FilterOptions.__init__()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 3
cts 3
cp 1
crap 1
rs 10
1 1
import yorm
0 ignored issues
show
Configuration introduced by
The import yorm could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
2 1
from yorm.types import Float, List, Object, AttributeDictionary
0 ignored issues
show
Configuration introduced by
The import yorm.types could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
3
4
5 1
@yorm.attr(minimum=Float)
6 1
@yorm.attr(maximum=Float)
7 1
class CoordinateRange(AttributeDictionary):
8
    """Specifies a floating-point range."""
9
10 1
    def __init__(self, minimum, maximum):
11 1
        super().__init__()
12 1
        self.minimum = minimum
13 1
        self.maximum = maximum
14
15
16 1
@yorm.attr(latitude=CoordinateRange)
17 1
@yorm.attr(longitude=CoordinateRange)
18 1
class BoundingBox(AttributeDictionary):
19
    """A GPS bounding box."""
20
21 1
    def __init__(self, latitude, longitude):
22 1
        super().__init__()
23 1
        self.latitude = latitude
24 1
        self.longitude = longitude
25
26
27 1
@yorm.attr(tags=List.of_type(Object))
28 1
class FilterOptions(AttributeDictionary):
29
    """Collection of rules to include matching polygons."""
30
31 1
    def __init__(self, tags=None):
32 1
        super().__init__()
33 1
        self.tags = tags or []
34
35
36 1
@yorm.attr(boundaries=List.of_type(BoundingBox))
37 1
@yorm.attr(filters=FilterOptions)
38 1
@yorm.sync("osmerge.yml")
39
class Config:
40
    """Specifies how to limited the location and types of polygons."""
41
42 1
    def __init__(self):
43 1
        self.boundaries = []
44 1
        self.filters = FilterOptions()
45
46 1
    @classmethod
47
    def generate_example(cls):
48
        """Create an example configuration to be manually edited."""
49 1
        config = cls()
50
51 1
        config.boundaries.append(BoundingBox(
52
            CoordinateRange(42.882669706849875, 43.03002974711799),
53
            CoordinateRange(-85.75284790217363, -85.5676630879733),
54
        ))
55 1
        config.filters.tags.append(dict(leasure='park'))
56
57
        return config
58