Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
.DS_Store

tests/**/*.xcconfig

installed_files.txt
build/
dist/
pyconfig.egg-info/
.tox/
.coverage
*.xcconfig
*.pyc
__pycache__/
htmlcov/
.eggs/
lint_output.txt
*_output.txt

# make sure to include the static test output data
!*_output.xcconfig
Expand Down
6 changes: 3 additions & 3 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# this dangerfile sets values that will be consumed by the global danger
# file. The global dangerfile is run automatically after this repo-specific
# this dangerfile sets values that will be consumed by the global danger
# file. The global dangerfile is run automatically after this repo-specific
# file is run. The global dangerfile is located at: https://github.com/samdmarshall/danger

# set the number of lines that must be changed before this classifies as a 'Big PR'
Expand All @@ -8,7 +8,7 @@
# set the files to watch and warn about if there are changes made
@SDM_DANGER_BUILD_FILES = ['Makefile', 'Gemfile', 'Dangerfile', 'circle.yml', '.codeclimate.yml', 'tox.ini', 'pylintrc']

# set the files to watch and warn about if there are
# set the files to watch and warn about if there are
@SDM_DANGER_INSTALL_REQUIREMENTS_FILES = ['requirements.txt', 'setup.py']

# set the files to watch and fail if there are changes
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016, Samantha Marshall
Copyright (c) 2016-2020, Samantha Marshall
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand All @@ -9,4 +9,4 @@ Redistribution and use in source and binary forms, with or without modification,

3. Neither the name of Samantha Marshall nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 changes: 22 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2016, Samantha Marshall (http://pewpewthespells.com)
# Copyright (c) 2016-2020, Samantha Marshall (http://pewpewthespells.com)
# All rights reserved.
#
# https://github.com/samdmarshall/pyconfig
Expand Down Expand Up @@ -38,7 +38,6 @@ INSTALLED_FILES_RECORD := ./installed_files.txt

# names of the executables that are used as a part of this project

PYTHON2_CMD := python
PYTHON3_CMD := python3
TOX_CMD := tox
COVERAGE_CMD := coverage
Expand All @@ -52,20 +51,20 @@ PRINTF_CMD := printf
TOUCH_CMD := touch
CP_CMD := cp
CAT_CMD := cat
PIP_CMD := pip
PIP_CMD := pip3
CCTREPORTER_CMD := codeclimate-test-reporter
UNAME_CMD := uname
EXIT_CMD := exit
TPUT_CMD := tput
TR_CMD := tr
PYLINT_CMD := pylint
MYPY_CMD := mypy

PYPARSING := pyparsing
TOX_PYENV := tox-pyenv

# invoke the specific executable command

PYTHON2 := $(shell command -v $(PYTHON2_CMD) 2> /dev/null)
PYTHON3 := $(shell command -v $(PYTHON3_CMD) 2> /dev/null)
TOX := $(shell command -v $(TOX_CMD) 2> /dev/null)
COVERAGE := $(shell command -v $(COVERAGE_CMD) 2> /dev/null)
Expand All @@ -86,6 +85,7 @@ EXIT := $(shell command -v $(EXIT_CMD) 2> /dev/null)
TPUT := $(shell command -v $(TPUT_CMD) 2> /dev/null)
TR := $(shell command -v $(TR_CMD) 2> /dev/null)
PYLINT := $(shell command -v $(PYLINT_CMD) 2> /dev/null)
MYPY := $(shell command -v $(MYPY_CMD) 2> /dev/null)

SYSTEM := $(shell $(UNAME) -s)
ifeq ($(SYSTEM),Darwin)
Expand Down Expand Up @@ -120,12 +120,12 @@ check:
$(call checkfor,$(FIND_CMD))
$(call checkfor,$(XARGS_CMD))
$(call checkfor,$(RM_CMD))
$(call checkfor,$(PYTHON2_CMD))
$(call checkfor,$(PYTHON3_CMD))
$(call checkfor,$(PIP_CMD))
$(call checkfor,$(TOX_CMD))
$(call checkfor,$(COVERAGE_CMD))
$(call checkfor,$(PYLINT_CMD))
$(call checkfor,$(MYPY_CMD))
$(call checkfor,$(GEM_CMD))
$(call checkfor,$(DANGER_CMD))
@$(DISPLAY_SEPARATOR)
Expand All @@ -136,14 +136,14 @@ pipinstall = @$(PIP) install $1 $(USER_FLAG)
geminstall = @$(GEM) install $1 $(USER_FLAG)

install-deps:
$(call checkfor,$(PYTHON2_CMD))
$(call checkfor,$(PIP_CMD))
$(call pipinstall,$(COVERAGE_CMD))
$(call pipinstall,$(TOX_CMD))
$(call pipinstall,$(PYPARSING))
$(call pipinstall,$(TOX_PYENV))
$(call pipinstall,$(CCTREPORTER_CMD))
$(call pipinstall,$(PYLINT_CMD))
$(call pipinstall,$(MYPY_CMD))
@$(DISPLAY_SEPARATOR)
$(call checkfor,$(GEM_CMD))
$(call geminstall,$(DANGER_CMD))
Expand Down Expand Up @@ -175,22 +175,19 @@ clean: check
@$(removeall) .coverage
@$(removeall) ./htmlcov
@$(removeall) ./.eggs
@$(removeall) ./.mypy_cache
@$(removeall) ./report
$(call cleanlocation, ., -name ".DS_Store")
$(call cleanlocation, ., -name "*.pyc")
$(call cleanlocation, ., -name "__pycache__" -type d)
$(call cleanlocation, ./tests, -name "*.xcconfig" -and -not -name "*_output.xcconfig")
$(call cleanlocation, ., -name "*_output.txt")
@$(PRINTF) "done!\n"
@$(DISPLAY_SEPARATOR)

# ---

build2: clean
$(PYTHON2) ./setup.py install $(USER_FLAG) --record $(INSTALLED_FILES_RECORD)
@$(DISPLAY_SEPARATOR)

# ---

build3: clean
build: clean
$(PYTHON3) ./setup.py install --record $(INSTALLED_FILES_RECORD)
@$(DISPLAY_SEPARATOR)

Expand Down Expand Up @@ -257,21 +254,28 @@ else
@$(DANGER) local --verbose
endif
@$(DISPLAY_SEPARATOR)

# ---

ci: test lint report danger

# ---

lint: check
@$(TOUCH) lint_output.txt
@$(TOUCH) pylint_output.txt
@$(PRINTF) "Running linter... "
@$(PYLINT) --rcfile=pylintrc ./pyconfig > lint_output.txt || :
@$(PYLINT) --rcfile=pylintrc ./pyconfig > pylint_output.txt || :
@$(PRINTF) " done!\n"
@$(PRINTF) "Generated linter report: lint_output.txt\n"
@$(PRINTF) "Generated linter report: pylint_output.txt\n"

@$(TOUCH) mypy_output.txt
@$(PRINTF) "Running mypy... "
@$(MYPY) ./pyconfig --ignore-missing-imports > mypy_output.txt || :
@$(PRINTF) " done!\n"
@$(PRINTF) "Generated mypy report: mypy_output.txt\n"

@$(DISPLAY_SEPARATOR)

# ---

.PHONY: danger lint ci report test build3 build2 clean install-tools install-deps check
.PHONY: danger lint ci report test build clean install-tools install-deps check
42 changes: 21 additions & 21 deletions pyc.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# Copyright (c) 2016, Samantha Marshall (http://pewpewthespells.com)
# Copyright (c) 2016, Samantha Marsh# Copyright (c) 2016-2020, Samantha Marshall (http://pewpewthespells.com)
# All rights reserved.
#
# https://github.com/samdmarshall/pyconfig
#
# Redistribution and use in source and binary forms, with or without modification,
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# 3. Neither the name of Samantha Marshall nor the names of its contributors may
# be used to endorse or promote products derived from this software without
#
# 3. Neither the name of Samantha Marshall nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# OF THE POSSIBILITY OF SUCH DAMAGE.

import pyconfig
Expand All @@ -34,4 +34,4 @@ def main():
pyconfig.main()

if __name__ == "__main__":
main()
main()
21 changes: 11 additions & 10 deletions pyconfig/Analyzer/Engine.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2016, Samantha Marshall (http://pewpewthespells.com)
# Copyright (c) 2016-2020, Samantha Marshall (http://pewpewthespells.com)
# All rights reserved.
#
# https://github.com/samdmarshall/pyconfig
Expand Down Expand Up @@ -29,14 +29,15 @@
# OF THE POSSIBILITY OF SUCH DAMAGE.

import os
import typing
from ..Settings import TypeConstants
from ..Settings import Builtin
from ..Settings import Runtime
from ..Keyword import SettingKeyword
from ..Helpers.Logger import Logger
from ..SCM import SCM

def findPreviousDefinition(kv_array, configuration, setting_key):
def findPreviousDefinition(kv_array, configuration, setting_key) -> list:
previous_definition_indexes = list()
for file_name, value in kv_array:
if file_name != configuration:
Expand All @@ -45,9 +46,9 @@ def findPreviousDefinition(kv_array, configuration, setting_key):
previous_definition_indexes.append(file_name)
return previous_definition_indexes

def findDuplicates(dictionary):
def findDuplicates(dictionary) -> dict:
results = dict()
settings_set = set()
settings_set: typing.Set[str] = set()
snapshot_of_dict = list(dictionary.items())
for configuration, values in snapshot_of_dict:
setting_values = list(values.keys())
Expand All @@ -61,7 +62,7 @@ def findDuplicates(dictionary):
settings_set.update(setting_values)
return results

def gatherAllVariables(dictionary):
def gatherAllVariables(dictionary) -> set:
settings_set = set()
snapshot_of_dict = list(dictionary.items())
for _configuration, values in snapshot_of_dict:
Expand All @@ -81,15 +82,15 @@ def __init__(self):
self.__namespace_table = dict()
self.__user_defined_table = set()

def __runInitializer(self, configuration):
def __runInitializer(self, configuration) -> None:
"""
This method is to pass through the passed in file
"""
self.__namespace_table[configuration.name] = dict()
for item in configuration.config:
is_setting = isinstance(item, SettingKeyword.SettingKeyword)
if is_setting:
is_unset = (item.build_setting_name not in list(self.__namespace_table[configuration.name].keys()))
is_unset = ( item.build_setting_name not in list(self.__namespace_table[configuration.name].keys()) )
if is_unset:
self.__namespace_table[configuration.name][item.build_setting_name] = item
else: # pragma: no cover
Expand All @@ -101,7 +102,7 @@ def __runInitializer(self, configuration):
'\n> '+configuration.name+':'+previous_line_number+''
Logger.write().warning(print_string)

def __runDuplicates(self, configuration):
def __runDuplicates(self, configuration) -> None:
duplicate_results = findDuplicates(self.__namespace_table)
for key, value in list(duplicate_results.items()):
for file_containing_dups in value:
Expand All @@ -116,7 +117,7 @@ def __runDuplicates(self, configuration):
'\n> '+file_containing_dups
Logger.write().warning(print_message)

def __gatherUserDefinedVariables(self):
def __gatherUserDefinedVariables(self) -> None:
self.__user_defined_table = set()
snapshot_of_dict = list(self.__namespace_table.items())
for _configuration, values in snapshot_of_dict:
Expand All @@ -128,7 +129,7 @@ def __gatherUserDefinedVariables(self):
if not is_builtin and not is_runtime and not is_known:
self.__user_defined_table.add(build_setting_name)

def __runMissing(self):
def __runMissing(self) -> None:
variables = gatherAllVariables(self.__namespace_table)
# remove any variables that are defined as part of the builtin set
variables.difference_update(self.__builtin_table)
Expand Down
Loading