Skip to content

Commit

Permalink
Add black configuration - fixed black errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Meisterschueler committed Dec 28, 2020
1 parent 64b7bd3 commit 4486252
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 38 deletions.
3 changes: 1 addition & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[flake8]
exclude = ./venv
ignore = E501

ignore = E203,E501,W503
5 changes: 5 additions & 0 deletions .github/workflows/superlinter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ jobs:
env:
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

LINTER_RULES_PATH: /
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
PYTHON_FLAKE8_CONFIG_FILE: .flake8

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# <div align="center">Flydenity<br /><br />

[![GitHub Super-Linter](https://github.com/Collen-Roller/flydenity/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter)
[![PyPI version](https://badge.fury.io/py/flydenity.svg)](https://badge.fury.io/py/flydenity)
[![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)
[![PyPI license](https://img.shields.io/pypi/l/ansicolortags.svg)](https://pypi.python.org/pypi/flydenity/)
Expand Down
20 changes: 6 additions & 14 deletions flydenity/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
class Parser:
def __init__(self):
# read the input files into mappings:
self.callsigns = {} # the callsign mapping: callsign -> [data1, data2, ...]
self.icao24bit = {} # the icao24bit mapping: icao24bit_prefix -> data
self.callsigns = {} # the callsign mapping: callsign -> [data1, data2, ...]
self.icao24bit = {} # the icao24bit mapping: icao24bit_prefix -> data
for dataset_type in DATASET_FILES:
with open(os.path.join(CURRENT_PATH, DATASET_FILES[dataset_type])) as csvfile:
csvreader = csv.reader(csvfile)
Expand Down Expand Up @@ -70,17 +70,9 @@ def __init__(self):

def _data_to_result(self, data):
if data["type"] == "country":
return {
"nation": data["nation"],
"description": data["description"],
"iso2": data["iso2"],
"iso3": data["iso3"]
}
return {"nation": data["nation"], "description": data["description"], "iso2": data["iso2"], "iso3": data["iso3"]}
elif data["type"] == "organization":
return {
"name": data["name"],
"description": data["description"]
}
return {"name": data["name"], "description": data["description"]}

def _parse_registration(self, string, strict):
# find the datasets matching with the string
Expand Down Expand Up @@ -115,12 +107,12 @@ def _parse_registration(self, string, strict):
def _parse_icao24bit(self, string, strict):
# check if input is correct
if strict and not re.match("[0-9A-F]{6}", string):
print(f"Warning: ICAO 24bit must be hexadecimal with length of 6 chars")
print(f"Warning: ICAO 24bit '{string}' must be hexadecimal with length of 6 chars")
return None

# return the matches
matches = []
for prefix in [string[0:i + 1] for i in range(len(string))]:
for prefix in [string[0 : i + 1] for i in range(len(string))]:
if prefix in self.icao24bit:
matches.append(self.icao24bit[prefix])

Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool.black]
line-length = 180
target-version = ['py36', 'py37', 'py38']
include = '\.pyi?$'
exclude = '(setup\.py)'
28 changes: 7 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
with open("README.md", "r") as fh:
long_description = fh.read()

with open(path.join(path.dirname(path.abspath(__file__)),
"requirements.txt")) as requirement_file:
with open(path.join(path.dirname(path.abspath(__file__)), "requirements.txt")) as requirement_file:
install_requirements = requirement_file.read().split("/n")

name = "flydenity"
Expand All @@ -29,28 +28,15 @@
classifiers=[
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
keywords=[
'aircraft', 'planes', 'registration', 'callsign', 'prefix',
'aircraft callsign', 'plane', 'air'
],

keywords=["aircraft", "planes", "registration", "callsign", "prefix", "aircraft callsign", "plane", "air"],
packages=find_packages(),

python_requires=">=3.6", # Version of Python required to install

python_requires=">=3.6", # Version of Python required to install
install_requires=install_requirements, # Install requirements

extras_require={
"dev": ['check-manifest']
},

entry_points={
'console_scripts': [
'flydenity = flydenity.__main__:main'
]
},
include_package_data=True # Including package data (IMPORTANT)
extras_require={"dev": ["check-manifest"]},
entry_points={"console_scripts": ["flydenity = flydenity.__main__:main"]},
include_package_data=True, # Including package data (IMPORTANT)
)
2 changes: 1 addition & 1 deletion tests/test_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_suffix_consistency(self):
for callsign in dataset["callsigns"]:
for suffix in dataset["suffixes"]:
if re.match(r"^([A-Z0-9]+)(\-[A-Z0-9]+)?$", suffix) is None:
continue # suffix is broken... already tested above
continue # suffix is broken... already tested above

if "-" in suffix:
registrations.extend([f"{callsign}-{suffix}" for suffix in suffix.split("-")])
Expand Down

0 comments on commit 4486252

Please sign in to comment.