From 486513c3b0ca6b92469f6aa7d8eaffe4d43c2232 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Mon, 10 Dec 2018 21:20:04 -0500 Subject: [PATCH] test flit (#9) --- .gitignore | 26 ++-- .pre-commit-config.yaml | 16 +++ .prospector.yaml | 26 ++++ .travis.yml | 26 ++-- LICENSE.md => LICENSE | 43 +++--- MANIFEST.in | 1 + Makefile | 33 +++++ Pipfile | 10 +- Pipfile.lock | 258 ++++++++++++++++++++++++++++++----- README.md | 16 +-- Vagrantfile | 71 ++++++++++ mass_replace/__init__.py | 13 ++ mass_replace/__version__.py | 3 - mass_replace/docs/lorem.txt | 2 +- mass_replace/mass_replace.py | 14 +- pyproject.toml | 18 +++ requirements.txt | 25 ---- setup.py | 100 +------------- tests/context.py | 2 +- tests/test_basic.py | 23 ++-- 20 files changed, 490 insertions(+), 236 deletions(-) create mode 100644 .pre-commit-config.yaml create mode 100644 .prospector.yaml rename LICENSE.md => LICENSE (87%) create mode 100644 MANIFEST.in create mode 100644 Makefile create mode 100644 Vagrantfile delete mode 100644 mass_replace/__version__.py create mode 100644 pyproject.toml delete mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 15519b8..502f5c7 100644 --- a/.gitignore +++ b/.gitignore @@ -34,16 +34,6 @@ var/ pip-log.txt pip-delete-this-directory.txt -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*,cover - # Translations *.mo *.pot @@ -59,8 +49,22 @@ target/ \.pytest_cache/v/cache/ +# IDE stuff \.vscode/ -ignore/ +# Static Analysis Artifacts +.wily/ +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +# misc +ignore/ mass_replace/\.pytest_cache/v/cache/ +file_exts\.txt +\.vagrant/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..5a7c501 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,16 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.0.0 + hooks: + - id: trailing-whitespace + - id: check-ast + - id: check-yaml + - id: sort-simple-yaml + - id: end-of-file-fixer + - id: fix-encoding-pragma + - id: mixed-line-ending + - id: trailing-whitespace +- repo: https://github.com/ambv/black + rev: stable + hooks: + - id: black diff --git a/.prospector.yaml b/.prospector.yaml new file mode 100644 index 0000000..abc27e9 --- /dev/null +++ b/.prospector.yaml @@ -0,0 +1,26 @@ +pylint: + options: + bad-names: foo,baz,toto,tutu,tata + disable: + - line-too-long + +pyflakes: + disable: + # let pylint used-before-assignment handle this + - F821 + - F401 + +pep8: + options: + max-line-length: 100 + +mccabe: + options: + # max-complexity default = 10 + max-complexity: 20 + +pyroma: + run: false + +pep257: + run: false diff --git a/.travis.yml b/.travis.yml index cfe2bda..0ec54af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ -os: - - linux - # - osx language: python +cache: pip python: - "3.5" - "3.6" @@ -12,15 +10,19 @@ matrix: dist: xenial sudo: true # command to install dependencies -install: - - pip install pipenv - - pipenv install --dev --deploy +install: "make" # command to run tests script: - - pwd - - ls - # - pytest -v # or py.test for Python versions 3.5 and below - - pytest -v --cov-report term --cov-report xml --cov=mass_replace tests/ - - ls + - make test after_success: - - coveralls \ No newline at end of file + - coveralls + - make lint + - make check_format +deploy: + provider: pypi + user: $FLIT_USERNAME + password: $FLIT_PASSWORD + server: $FLIT_INDEX_URL + skip_existing: true + on: + branch: dev diff --git a/LICENSE.md b/LICENSE similarity index 87% rename from LICENSE.md rename to LICENSE index e1c3eab..a808e15 100644 --- a/LICENSE.md +++ b/LICENSE @@ -1,22 +1,21 @@ - -The MIT License (MIT) - -Copyright (c) 2018 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +The MIT License (MIT) + +Copyright (c) 2018 Gabriel Gore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..b95288c --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include README.MD diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ae83f04 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +init: +ifeq ($(TRAVIS), true) + pip install pipenv + pipenv install --dev + pip install . + touch tests/__init__.py +else + pipenv install --dev + pre-commit install +endif + +test: + pytest -rpsf --cov-report term-missing --cov-report xml --cov=mass_replace tests/ + +lint: +ifeq ($(TRAVIS_PYTHON_VERSION), 2.7) + echo "Skip linting for Python2.7" +else + prospector --output-format grouped +endif + +format: + black . + +check_format: +ifeq ($(TRAVIS_PYTHON_VERSION), 3.7) + black . --check +else + echo "Only check format on Python3.7" +endif + +pre: + pre-commit run --all-files diff --git a/Pipfile b/Pipfile index 9df50fb..537c758 100644 --- a/Pipfile +++ b/Pipfile @@ -7,16 +7,20 @@ name = "pypi" pyyaml = ">=3.13" [dev-packages] -flit = "*" black = {version = "==18.9b0",markers = "python_version >= '3.6'"} -flake8 = "*" +pre-commit = "*" pytest = "*" pytest-cov = "*" coveralls = "*" +prospector = {extras = ["with_pyroma"],version = "*"} +# wily = {version = "*",markers = "python_version >= '3.7'"} [requires] python_version = "3.7" [scripts] -format = "black mass_replace tests" +format = "black ." reqs = "sh scripts/update_reqs.sh" +pre = "pre-commit run --all-files" +lint = "prospector --output-format grouped" +test = "pytest -rpsf --cov-report term-missing --cov=mass_replace tests/" diff --git a/Pipfile.lock b/Pipfile.lock index 73799a1..dc0b011 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "3c29cccc19e9193cb4e97668c740814f99c18b1334d45a774996d4d38854616a" + "sha256": "6bcf29e8bc43648c189029b773dbad98117b90368c2cc6eb23659a3f55f69a6f" }, "pipfile-spec": 6, "requires": { @@ -42,6 +42,20 @@ ], "version": "==1.4.3" }, + "aspy.yaml": { + "hashes": [ + "sha256:04d26279513618f1024e1aba46471db870b3b33aef204c2d09bcf93bea9ba13f", + "sha256:0a77e23fafe7b242068ffc0252cee130d3e509040908fc678d9d1060e7494baa" + ], + "version": "==1.1.1" + }, + "astroid": { + "hashes": [ + "sha256:292fa429e69d60e4161e7612cb7cc8fa3609e2e309f80c224d93a76d5e7b58be", + "sha256:c7013d119ec95eb626f7a2011f0b63d0c9a095df9ad06d8507b37084eada1a8d" + ], + "version": "==2.0.4" + }, "atomicwrites": { "hashes": [ "sha256:0312ad34fcad8fac3704d441f7b317e50af620823353ec657a53e981f92920c0", @@ -65,12 +79,26 @@ "markers": "python_version >= '3.6'", "version": "==18.9b0" }, + "cached-property": { + "hashes": [ + "sha256:3a026f1a54135677e7da5ce819b0c690f156f37976f3e30c5430740725203d7f", + "sha256:9217a59f14a5682da7c4b8829deadbfc194ac22e9908ccf7c8820234e80a1504" + ], + "version": "==1.5.1" + }, "certifi": { "hashes": [ - "sha256:339dc09518b07e2fa7eda5450740925974815557727d6bd35d319c1524a04a4c", - "sha256:6d58c986d22b038c8c0df30d639f23a3e6d172a05c3583e766f4c0b785c0986a" + "sha256:47f9c83ef4c0c621eaef743f133f09fa8a74a9b75f037e8624f83bd1b6626cb7", + "sha256:993f830721089fef441cdfeb4b2c8c9df86f0c63239f06bd025a76a7daddb033" ], - "version": "==2018.10.15" + "version": "==2018.11.29" + }, + "cfgv": { + "hashes": [ + "sha256:73f48a752bd7aab103c4b882d6596c6360b7aa63b34073dd2c35c7b4b8f93010", + "sha256:d1791caa9ff5c0c7bce80e7ecc1921752a2eb7c2463a08ed9b6c96b85a2f75aa" + ], + "version": "==1.1.0" }, "chardet": { "hashes": [ @@ -88,11 +116,11 @@ }, "colorama": { "hashes": [ - "sha256:a3d89af5db9e9806a779a50296b5fdb466e281147c2c235e8225ecc6dbf7bbf3", - "sha256:c9b54bebe91a6a803e0772c8561d53f2926bfeb17cd141fbabcb08424086595c" + "sha256:05eed71e2e327246ad6b38c540c4a3117230b19679b875190486ddd2d721422d", + "sha256:f8ac84de7840f5b9c4e3347b3c1eaa50f7e49c2b07596221daec5edaabbd7c48" ], "markers": "sys_platform == 'win32'", - "version": "==0.4.0" + "version": "==0.4.1" }, "coverage": { "hashes": [ @@ -152,28 +180,73 @@ ], "version": "==0.14" }, - "flake8": { + "dodgy": { "hashes": [ - "sha256:6a35f5b8761f45c5513e3405f110a86bea57982c3b75b766ce7b65217abe1670", - "sha256:c01f8a3963b3571a8e6bd7a4063359aff90749e160778e03817cd9b71c9e07d2" + "sha256:65e13cf878d7aff129f1461c13cb5fd1bb6dfe66bb5327e09379c3877763280c" ], - "index": "pypi", - "version": "==3.6.0" + "version": "==0.1.9" }, - "flit": { + "identify": { "hashes": [ - "sha256:6aefa6ff89a993af7a7af40d3df3d0387d6663df99797981ec41b1431ec6d1e1", - "sha256:9969db9708305b64fd8acf20043fcff144f910222397a221fd29871f02ed4a6f" + "sha256:5e956558a9a1e3b3891d7c6609fc9709657a11878af288ace484d1a46a93922b", + "sha256:623086059219cc7b86c77a3891f3700cb175d4ce02b8fb8802b047301d71e783" ], - "index": "pypi", - "version": "==1.2.1" + "version": "==1.1.7" }, "idna": { "hashes": [ - "sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e", - "sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16" + "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" + ], + "version": "==2.8" + }, + "importlib-metadata": { + "hashes": [ + "sha256:28fba9f65e5415a691dd254cdb602bcc4d6f738e68407ad251651db358b63bcf", + "sha256:4a545e6125dc72b4ad98201ea3f40f92e8126e3a19667352b3a134d22b8bc74f" + ], + "version": "==0.7" + }, + "isort": { + "hashes": [ + "sha256:1153601da39a25b14ddc54955dbbacbb6b2d19135386699e2ad58517953b34af", + "sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8", + "sha256:ec9ef8f4a9bc6f71eec99e1806bfa2de401650d996c59330782b89a5555c1497" + ], + "version": "==4.3.4" + }, + "lazy-object-proxy": { + "hashes": [ + "sha256:0ce34342b419bd8f018e6666bfef729aec3edf62345a53b537a4dcc115746a33", + "sha256:1b668120716eb7ee21d8a38815e5eb3bb8211117d9a90b0f8e21722c0758cc39", + "sha256:209615b0fe4624d79e50220ce3310ca1a9445fd8e6d3572a896e7f9146bbf019", + "sha256:27bf62cb2b1a2068d443ff7097ee33393f8483b570b475db8ebf7e1cba64f088", + "sha256:27ea6fd1c02dcc78172a82fc37fcc0992a94e4cecf53cb6d73f11749825bd98b", + "sha256:2c1b21b44ac9beb0fc848d3993924147ba45c4ebc24be19825e57aabbe74a99e", + "sha256:2df72ab12046a3496a92476020a1a0abf78b2a7db9ff4dc2036b8dd980203ae6", + "sha256:320ffd3de9699d3892048baee45ebfbbf9388a7d65d832d7e580243ade426d2b", + "sha256:50e3b9a464d5d08cc5227413db0d1c4707b6172e4d4d915c1c70e4de0bbff1f5", + "sha256:5276db7ff62bb7b52f77f1f51ed58850e315154249aceb42e7f4c611f0f847ff", + "sha256:61a6cf00dcb1a7f0c773ed4acc509cb636af2d6337a08f362413c76b2b47a8dd", + "sha256:6ae6c4cb59f199d8827c5a07546b2ab7e85d262acaccaacd49b62f53f7c456f7", + "sha256:7661d401d60d8bf15bb5da39e4dd72f5d764c5aff5a86ef52a042506e3e970ff", + "sha256:7bd527f36a605c914efca5d3d014170b2cb184723e423d26b1fb2fd9108e264d", + "sha256:7cb54db3535c8686ea12e9535eb087d32421184eacc6939ef15ef50f83a5e7e2", + "sha256:7f3a2d740291f7f2c111d86a1c4851b70fb000a6c8883a59660d95ad57b9df35", + "sha256:81304b7d8e9c824d058087dcb89144842c8e0dea6d281c031f59f0acf66963d4", + "sha256:933947e8b4fbe617a51528b09851685138b49d511af0b6c0da2539115d6d4514", + "sha256:94223d7f060301b3a8c09c9b3bc3294b56b2188e7d8179c762a1cda72c979252", + "sha256:ab3ca49afcb47058393b0122428358d2fbe0408cf99f1b58b295cfeb4ed39109", + "sha256:bd6292f565ca46dee4e737ebcc20742e3b5be2b01556dafe169f6c65d088875f", + "sha256:cb924aa3e4a3fb644d0c463cad5bc2572649a6a3f68a7f8e4fbe44aaa6d77e4c", + "sha256:d0fc7a286feac9077ec52a927fc9fe8fe2fabab95426722be4c953c9a8bede92", + "sha256:ddc34786490a6e4ec0a855d401034cbd1242ef186c20d79d2166d6a4bd449577", + "sha256:e34b155e36fa9da7e1b7c738ed7767fc9491a62ec6af70fe9da4a057759edc2d", + "sha256:e5b9e8f6bda48460b7b143c3821b21b452cb3a835e6bbd5dd33aa0c8d3f5137d", + "sha256:e81ebf6c5ee9684be8f2c87563880f93eedd56dd2b6146d8a725b50b7e5adb0f", + "sha256:eb91be369f945f10d3a49f5f9be8b3d0b93a4c2be8f8a5b83b0571b8123e0a7a", + "sha256:f460d1ceb0e4a5dcb2a652db0904224f367c9b3c1470d5a7683c0480e582468b" ], - "version": "==2.7" + "version": "==1.3.1" }, "mccabe": { "hashes": [ @@ -190,6 +263,19 @@ ], "version": "==4.3.0" }, + "nodeenv": { + "hashes": [ + "sha256:ad8259494cf1c9034539f6cced78a1da4840a4b157e23640bc4a0c0546b0cb7a" + ], + "version": "==1.3.3" + }, + "pep8-naming": { + "hashes": [ + "sha256:1b419fa45b68b61cd8c5daf4e0c96d28915ad14d3d5f35fcc1e7e95324a33a2e", + "sha256:4eedfd4c4b05e48796f74f5d8628c068ff788b9c2b08471ad408007fc6450e5a" + ], + "version": "==0.4.1" + }, "pluggy": { "hashes": [ "sha256:447ba94990e8014ee25ec853339faf7b0fc8050cdc3289d4d71f7f410fb90095", @@ -197,6 +283,24 @@ ], "version": "==0.8.0" }, + "pre-commit": { + "hashes": [ + "sha256:7542bd8ae1c58745175ea0a9295964ee82a10f7e18c4344f5e4c02bd85d02561", + "sha256:87f687da6a2651d5067cfec95b854b004e95b70143cbf2369604bb3acbce25ec" + ], + "index": "pypi", + "version": "==1.12.0" + }, + "prospector": { + "extras": [ + "with_pyroma" + ], + "hashes": [ + "sha256:877d8d361a5c0e04c8587718c22c5d671afcf814945c96b3e592836d772943fd" + ], + "index": "pypi", + "version": "==1.1.6.2" + }, "py": { "hashes": [ "sha256:bf92637198836372b520efcba9e020c330123be8ce527e535d185ed4b6f45694", @@ -211,12 +315,59 @@ ], "version": "==2.4.0" }, + "pydocstyle": { + "hashes": [ + "sha256:2258f9b0df68b97bf3a6c29003edc5238ff8879f1efb6f1999988d934e432bd8", + "sha256:5741c85e408f9e0ddf873611085e819b809fca90b619f5fd7f34bd4959da3dd4", + "sha256:ed79d4ec5e92655eccc21eb0c6cf512e69512b4a97d215ace46d17e4990f2039" + ], + "version": "==3.0.0" + }, "pyflakes": { "hashes": [ - "sha256:9a7662ec724d0120012f6e29d6248ae3727d821bba522a0e6b356eff19126a49", - "sha256:f661252913bc1dbe7fcfcbf0af0db3f42ab65aabd1a6ca68fe5d466bace94dae" + "sha256:08bd6a50edf8cffa9fa09a463063c425ecaaf10d1eb0335a7e8b1401aef89e6f", + "sha256:8d616a382f243dbf19b54743f280b80198be0bca3a5396f1d2e1fca6223e8805" + ], + "version": "==1.6.0" + }, + "pylint": { + "hashes": [ + "sha256:1d6d3622c94b4887115fe5204982eee66fdd8a951cf98635ee5caee6ec98c3ec", + "sha256:31142f764d2a7cd41df5196f9933b12b7ee55e73ef12204b648ad7e556c119fb" ], - "version": "==2.0.0" + "version": "==2.1.1" + }, + "pylint-celery": { + "hashes": [ + "sha256:41e32094e7408d15c044178ea828dd524beedbdbe6f83f712c5e35bde1de4beb" + ], + "version": "==0.3" + }, + "pylint-django": { + "hashes": [ + "sha256:5dc5f85caef2c5f9e61622b9cbd89d94edd3dcf546939b2974d18de4fa90d676", + "sha256:bf313f10b68ed915a34f0f475cc9ff8c7f574a95302beb48b79c5993f7efd84c" + ], + "version": "==2.0.2" + }, + "pylint-flask": { + "hashes": [ + "sha256:8fcdbb7cbf13d8c2ac1f2230b2aa1c1b83bb3ca2bd8b76f95561cb8757a305ec" + ], + "version": "==0.5" + }, + "pylint-plugin-utils": { + "hashes": [ + "sha256:8ad25a82bcce390d1d6b7c006c123e0cb18051839c9df7b8bdb7823c53fe676e" + ], + "version": "==0.4" + }, + "pyroma": { + "hashes": [ + "sha256:3ed770a0ed1616ee2ffa576852e34fb1ea5b54c37ff78dd33cff67d0e4bb584b", + "sha256:94a11cb077976bff9bd37ac8b487902556f216c4ee90b74a2344367f73b6ee7f" + ], + "version": "==2.4" }, "pytest": { "hashes": [ @@ -234,25 +385,55 @@ "index": "pypi", "version": "==2.6.0" }, - "pytoml": { + "pyyaml": { "hashes": [ - "sha256:ca2d0cb127c938b8b76a9a0d0f855cf930c1d50cc3a0af6d3595b566519a1013" + "sha256:3d7da3009c0f3e783b2c873687652d83b1bbfd5c88e9813fb7e5b03c0dd3108b", + "sha256:3ef3092145e9b70e3ddd2c7ad59bdd0252a94dfe3949721633e41344de00a6bf", + "sha256:40c71b8e076d0550b2e6380bada1f1cd1017b882f7e16f09a65be98e017f211a", + "sha256:558dd60b890ba8fd982e05941927a3911dc409a63dcb8b634feaa0cda69330d3", + "sha256:a7c28b45d9f99102fa092bb213aa12e0aaf9a6a1f5e395d36166639c1f96c3a1", + "sha256:aa7dd4a6a427aed7df6fb7f08a580d68d9b118d90310374716ae90b710280af1", + "sha256:bc558586e6045763782014934bfaf39d48b8ae85a2713117d16c39864085c613", + "sha256:d46d7982b62e0729ad0175a9bc7e10a566fc07b224d2c79fafb5e032727eaa04", + "sha256:d5eef459e30b09f5a098b9cea68bebfeb268697f78d647bd255a085371ac7f3f", + "sha256:e01d3203230e1786cd91ccfdc8f8454c8069c91bee3962ad93b87a4b2860f537", + "sha256:e170a9e6fcfd19021dd29845af83bb79236068bf5fd4df3327c1be18182b2531" ], - "version": "==0.1.20" + "index": "pypi", + "version": "==3.13" }, "requests": { "hashes": [ - "sha256:65b3a120e4329e33c9889db89c80976c5272f56ea92d3e74da8a463992e3ff54", - "sha256:ea881206e59f41dbd0bd445437d792e43906703fff75ca8ff43ccdb11f33f263" + "sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", + "sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b" + ], + "version": "==2.21.0" + }, + "requirements-detector": { + "hashes": [ + "sha256:9fbc4b24e8b7c3663aff32e3eba34596848c6b91bd425079b386973bd8d08931" + ], + "version": "==0.6" + }, + "setoptconf": { + "hashes": [ + "sha256:5b0b5d8e0077713f5d5152d4f63be6f048d9a1bb66be15d089a11c898c3cf49c" ], - "version": "==2.20.1" + "version": "==0.2.0" }, "six": { "hashes": [ - "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9", - "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb" + "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", + "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" + ], + "version": "==1.12.0" + }, + "snowballstemmer": { + "hashes": [ + "sha256:919f26a68b2c17a7634da993d91339e288964f93c274f1343e3bbbe2096e1128", + "sha256:9f3bcd3c401c3e862ec0ebe6d2c069ebc012ce142cce209c098ccb5b09136e89" ], - "version": "==1.11.0" + "version": "==1.2.1" }, "toml": { "hashes": [ @@ -267,6 +448,19 @@ "sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22" ], "version": "==1.24.1" + }, + "virtualenv": { + "hashes": [ + "sha256:686176c23a538ecc56d27ed9d5217abd34644823d6391cbeb232f42bf722baad", + "sha256:f899fafcd92e1150f40c8215328be38ff24b519cd95357fa6e78e006c7638208" + ], + "version": "==16.1.0" + }, + "wrapt": { + "hashes": [ + "sha256:d4d560d479f2c21e1b5443bbd15fe7ec4b37fe7e53d335d3b9b0a7b1226fe3c6" + ], + "version": "==1.10.11" } } } diff --git a/README.md b/README.md index 8504d0c..e6ef483 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,17 @@ # mass_replace -branch|Travis CI|Coveralls -------|------------|-------- -`master`|[![Build Status](https://travis-ci.org/Kilo59/mass_replace.svg?branch=master)](https://travis-ci.org/Kilo59/mass_replace)|[![Coverage Status](https://coveralls.io/repos/github/Kilo59/mass_replace/badge.svg?branch=master)](https://coveralls.io/github/Kilo59/mass_replace?branch=master) -`dev`|[![Build Status](https://travis-ci.org/Kilo59/mass_replace.svg?branch=dev)](https://travis-ci.org/Kilo59/mass_replace)|[![Coverage Status](https://coveralls.io/repos/github/Kilo59/mass_replace/badge.svg?branch=dev)](https://coveralls.io/github/Kilo59/mass_replace?branch=dev) - -# mass_replace +[![PyPI version](https://badge.fury.io/py/mass-replace.svg)](https://badge.fury.io/py/mass-replace) [![PyPi](https://img.shields.io/pypi/pyversions/Django.svg)](https://pypi.org/project/mass-replace/) [![Build Status](https://travis-ci.org/Kilo59/mass_replace.svg?branch=master)](https://travis-ci.org/Kilo59/mass_replace) [![Coverage Status](https://coveralls.io/repos/github/Kilo59/mass_replace/badge.svg?branch=master)](https://coveralls.io/github/Kilo59/mass_replace?branch=master) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) ## Use case `mass_replace` "Walkthrough" through a specified `root_folder` and perform find and replace operations on every file of the specified type. * If `Python 3` is installed on your system it can be run as `mass_replace.py` Python script -* Can be run as a standalone Window Executable (`.exe`) +* Can be run as a standalone Window Executable (`.exe`) -------------------------------------------- -## ⚠️ **WARNING** ⚠️ +## ⚠️ **WARNING** ⚠️ EVERY FILE OF THE SPECIFIED TYPE NESTED UNDERNEATH THE `root_folder` WILL BE SUBJECT TO FIND AND REPLACE OPERATIONS ------------------------------------------------ @@ -34,7 +29,7 @@ EVERY FILE OF THE SPECIFIED TYPE NESTED UNDERNEATH THE `root_folder` WILL BE SUB - set 'root_folder' to set the parent folder under which the operations will be performed. 4. Run `mass_replace.exe` - Double click `mass_replace.exe` - - or run from command line/powershell ✔️ + - or run from command line/powershell ✔️ ```yaml # mass_replace config file @@ -46,7 +41,7 @@ filetypes: replacement_pairs: old_text1: new_text1 old_text2: new_text2 - puff_daddy: diddy + puff_daddy: diddy ``` ### Ease of Use suggestions @@ -56,4 +51,3 @@ Create shortcuts of `mass_replace.exe` and `config.yaml` and place them somewher Do not move the actual files or the application will not work. ![image](https://user-images.githubusercontent.com/13108583/39159212-5f284ca0-4732-11e8-8014-dbedd0f349c0.png) - diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..3a9ec1c --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,71 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure("2") do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://vagrantcloud.com/search. + config.vm.box = "bento/ubuntu-16.04" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # NOTE: This will enable public access to the opened port + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine and only allow access + # via 127.0.0.1 to disable public access + # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + # vb.gui = true + # + # # Customize the amount of memory on the VM: + # vb.memory = "1024" + # end + # + # View the documentation for the provider you are using for more + # information on available options. + + # Enable provisioning with a shell script. Additional provisioners such as + # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the + # documentation for more information about their specific syntax and use. + config.vm.provision "shell", inline: <<-SHELL + sudo add-apt-repository ppa:deadsnakes/ppa + sudo apt-get update + sudo apt-get install python3.6 -y + SHELL +end diff --git a/mass_replace/__init__.py b/mass_replace/__init__.py index 3df427a..be1637a 100644 --- a/mass_replace/__init__.py +++ b/mass_replace/__init__.py @@ -1 +1,14 @@ +# -*- coding: utf-8 -*- +""" +mass_replace +~~~~~~~~~~~~ + +"Walkthrough" through a specified `root_folder` and perform find and replace +operations on every file of the specified type. +""" + from .mass_replace import * + +VERSION = (0, 0, 3) + +__version__ = ".".join(map(str, VERSION)) diff --git a/mass_replace/__version__.py b/mass_replace/__version__.py deleted file mode 100644 index e0408f7..0000000 --- a/mass_replace/__version__.py +++ /dev/null @@ -1,3 +0,0 @@ -VERSION = (0, 1, 1) - -__version__ = ".".join(map(str, VERSION)) diff --git a/mass_replace/docs/lorem.txt b/mass_replace/docs/lorem.txt index eda78c1..0d0ee10 100644 --- a/mass_replace/docs/lorem.txt +++ b/mass_replace/docs/lorem.txt @@ -186,4 +186,4 @@ Cras nec mauris vel nisl rutrum vulputate id quis libero. Fusce eu purus tristique, vestibulum leo vitae, ullamcorper purus. Aliquam vel nisi luctus, malesuada mauris vel, ullamcorper quam. Morbi congue ipsum ut ex malesuada facilisis. -Aenean eget nibh viverra, rhoncus massa quis, ornare orci. \ No newline at end of file +Aenean eget nibh viverra, rhoncus massa quis, ornare orci. diff --git a/mass_replace/mass_replace.py b/mass_replace/mass_replace.py index b45d869..ebd0dc7 100644 --- a/mass_replace/mass_replace.py +++ b/mass_replace/mass_replace.py @@ -1,15 +1,14 @@ # -*- coding: utf-8 -*- -""" -mass_replace.py -~~~~~~~~~~~~~~~ -WIP -""" +from sys import version_info import os import fileinput import yaml from pprint import pprint as pp +PYTHON_VER = (version_info.major, version_info.minor) + + def resolve_wd(target_dir="mass_replace"): if target_dir in get_dirs(): os.chdir(target_dir) @@ -48,7 +47,7 @@ def many_find_replace(filename, text_search_replace_dicts): file_find_replace(filename, text_to_search, replacement_text) -def discover_filetypes(root_folder=None, hard_copy=True): +def discover_filetypes(root_folder=None, hard_copy="file_exts.txt"): """Walks through the specified `root_folder` and collects all file extension types. Writes the extension types to `file_exts.txt`.""" @@ -64,7 +63,7 @@ def discover_filetypes(root_folder=None, hard_copy=True): f_types = [".{}".format(ext.split(".")[-1]) for ext in filenames] file_types.update(f_types) if hard_copy: - with open("file_exts.txt", "w") as f_out: + with open(hard_copy, "w") as f_out: f_out.writelines("\n".join(file_types)) return file_types @@ -99,7 +98,6 @@ def mass_replace(root_folder=None, config=None, verbose=False): for fname in valid_files: print("|----{}".format(fname)) many_find_replace("{}/{}".format(dirpath, fname), replacement_pairs) - return if __name__ == "__main__": diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..834af3d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +[build-system] +requires = ["flit"] +build-backend = "flit.buildapi" + +[tool.flit.metadata] +module = "mass_replace" +author = "Gabriel Gore" +author-email = "gabriel59kg@gmail.com" +home-page = "https://github.com/Kilo59/mass_replace" +classifiers = [ + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + ] +requires-python = ">=3.5" +requires = ["pyyaml"] + +[tool.flit.scripts] +replace = "mass_replace.__main__:main" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 26f8953..0000000 --- a/requirements.txt +++ /dev/null @@ -1,25 +0,0 @@ --i https://pypi.org/simple -appdirs==1.4.3 -atomicwrites==1.2.1 -attrs==18.2.0 -black==18.9b0 -certifi==2018.10.15 -chardet==3.0.4 -click==7.0 -colorama==0.4.0 ; sys_platform == 'win32' -docutils==0.14 -flake8==3.6.0 -flit==1.2.1 -idna==2.7 -mccabe==0.6.1 -more-itertools==4.3.0 -pluggy==0.8.0 -py==1.7.0 -pycodestyle==2.4.0 -pyflakes==2.0.0 -pytest==4.0.1 -pytoml==0.1.20 -requests==2.20.1 -six==1.11.0 -toml==0.10.0 -urllib3==1.24.1 diff --git a/setup.py b/setup.py index 222eae3..a8b87d3 100644 --- a/setup.py +++ b/setup.py @@ -1,15 +1,10 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import pathlib +from setuptools import find_packages, setup -# Note: To use the 'upload' functionality of this file, you must: -# $ pip install twine - -import io -import os -import sys -from shutil import rmtree - -from setuptools import find_packages, setup, Command +# The directory containing this file +HERE = pathlib.Path(__file__).parent # Package meta-data. NAME = "mass_replace" @@ -17,100 +12,15 @@ URL = "https://github.com/Kilo59/mass_replace" EMAIL = "gabriel59kg@gmail.com" AUTHOR = "Gabriel Gore" -REQUIRES_PYTHON = ">=3.4.0" -VERSION = "0.1.1" # What packages are required for this module to be executed? REQUIRED = ["pyaml"] -# The rest you shouldn't have to touch too much :) -# ------------------------------------------------ -# Except, perhaps the License and Trove Classifiers! -# If you do change the License, remember to change the Trove Classifier for that! - -here = os.path.abspath(os.path.dirname(__file__)) - -# Import the README and use it as the long-description. -# Note: this will only work if 'README.rst' is present in your MANIFEST.in file! -# with io.open(os.path.join(here, 'README.rst'), encoding='utf-8') as f: -# long_description = '\n' + f.read() - -# Load the package's __version__.py module as a dictionary. -about = {} -if not VERSION: - with open(os.path.join(here, NAME, "__version__.py")) as f: - exec(f.read(), about) -else: - about["__version__"] = VERSION - - -class UploadCommand(Command): - """Support setup.py upload.""" - - description = "Build and publish the package." - user_options = [] - - @staticmethod - def status(s): - """Prints things in bold.""" - print("\033[1m{0}\033[0m".format(s)) - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - try: - self.status("Removing previous builds…") - rmtree(os.path.join(here, "dist")) - except OSError: - pass - - self.status("Building Source and Wheel (universal) distribution…") - os.system("{0} setup.py sdist bdist_wheel --universal".format(sys.executable)) - - self.status("Uploading the package to PyPi via Twine…") - os.system("twine upload dist/*") - - self.status("Pushing git tags…") - os.system("git tag v{0}".format(about["__version__"])) - os.system("git push --tags") - - sys.exit() - - -# Where the magic happens: setup( name=NAME, - version=about["__version__"], - description=DESCRIPTION, - # long_description=long_description, - author=AUTHOR, - author_email=EMAIL, - python_requires=REQUIRES_PYTHON, - url=URL, packages=find_packages(exclude=("tests",)), - # If your package is a single module, use this instead of 'packages': - # py_modules=['mypackage'], - # entry_points={ - # 'console_scripts': ['mycli=mymodule:cli'], - # }, + entry_points={"console_scripts": ["replace=mass_replace.__main__:main"]}, install_requires=REQUIRED, include_package_data=True, license="MIT", - classifiers=[ - # Trove classifiers - # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers - "License :: OSI Approved :: MIT License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: Implementation :: CPython", - ], - # $ setup.py publish support. - cmdclass={"upload": UploadCommand}, ) diff --git a/tests/context.py b/tests/context.py index 76940d3..11d9b00 100644 --- a/tests/context.py +++ b/tests/context.py @@ -11,7 +11,7 @@ 0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../mass_replace")) ) -import mass_replace +import mass_replace # pylint: disable=wrong-import-position print("USING context.py") diff --git a/tests/test_basic.py b/tests/test_basic.py index 1faab37..83903d6 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -16,8 +16,7 @@ print(E) from context import mass_replace as mr - -PYTHON_VER = version_info[0] +PYTHON_VER = (version_info.major, version_info.minor) def read_file_lines(filename): @@ -34,29 +33,29 @@ def test_correct_working_dir(): pass -@pytest.mark.skipif(PYTHON_VER <= 2, reason="List comprehension error with Python 2") +@pytest.mark.skipif(PYTHON_VER[0] <= 2, reason="List comprehension error with Python 2") def test_load_config(): load_config_return_type = type(mr.load_config("mass_replace/config.yaml")) print(load_config_return_type, dict) assert load_config_return_type is dict -@pytest.mark.skipif(PYTHON_VER <= 2, reason="List comprehension error with Python 2") +@pytest.mark.skipif(PYTHON_VER[0] <= 2, reason="List comprehension error with Python 2") def test_get_items(): - assert type(mr.get_items()) is list + assert isinstance(mr.get_items(), list) -@pytest.mark.skipif(PYTHON_VER <= 2, reason="List comprehension error with Python 2") +@pytest.mark.skipif(PYTHON_VER[0] <= 2, reason="List comprehension error with Python 2") def test_get_dirs(): - assert type(mr.get_dirs()) is list + assert isinstance(mr.get_dirs(), list) -@pytest.mark.skipif(PYTHON_VER <= 2, reason="List comprehension error with Python 2") +@pytest.mark.skipif(PYTHON_VER[0] <= 2, reason="List comprehension error with Python 2") def test_get_files(): """Test that `get_files()` returns a list and that every item within the list is a file.""" files = mr.get_files() - assert type(files) is list + assert isinstance(files, list) for f in files: assert path.isfile(f) @@ -72,10 +71,10 @@ def test_simple_file_find_and_replace(): assert first_str == "Lorem" -def test_discover_filetypes(): +def test_discover_filetypes(tmp_path): mr.discover_filetypes() - filetypes = mr.discover_filetypes("tests") - assert type(filetypes) is set + filetypes = mr.discover_filetypes("tests", hard_copy=str(tmp_path / "files.ext")) + assert isinstance(filetypes, set) assert len(filetypes) > 1