From 49b085216f5d5e8c7398c64b61db90cf60c1e28c Mon Sep 17 00:00:00 2001 From: BlueManCZ Date: Tue, 12 Nov 2024 12:11:04 +0100 Subject: [PATCH 1/2] Add GitHub actions, unit tests and Pipenv support --- .flake8 | 2 + .github/workflows/actions.yaml | 27 +++ Pipfile | 22 +++ Pipfile.lock | 349 +++++++++++++++++++++++++++++++++ sif.py | 76 ++----- tests.py | 27 +++ 6 files changed, 445 insertions(+), 58 deletions(-) create mode 100644 .flake8 create mode 100644 .github/workflows/actions.yaml create mode 100644 Pipfile create mode 100644 Pipfile.lock create mode 100644 tests.py diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..6deafc2 --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +max-line-length = 120 diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml new file mode 100644 index 0000000..f3a4236 --- /dev/null +++ b/.github/workflows/actions.yaml @@ -0,0 +1,27 @@ +name: Black, Flake, Tests +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.12"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pipenv + pipenv install --dev + - name: Run black + run: pipenv run black + - name: Run flake8 + run: pipenv run flake + - name: Run tests + run: pipenv run test diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..54ace36 --- /dev/null +++ b/Pipfile @@ -0,0 +1,22 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +PyGObject = "*" +requests = "*" +vdf = "*" + +[dev-packages] +black = "*" +flake8-for-pycharm = "*" + +[requires] +python_version = "3.12" + +[scripts] +black = "black --check --line-length 120 . --verbose" +black_fix = "black --line-length 120 . --verbose" +flake = "flake8 . -v" +test = "python -m unittest -v" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..a441940 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,349 @@ +{ + "_meta": { + "hash": { + "sha256": "09f3a27ca5f600d9224424bf4e0c03160f4cb66bc106e7ca6648bbd596192cf9" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.12" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "certifi": { + "hashes": [ + "sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8", + "sha256:bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9" + ], + "markers": "python_version >= '3.6'", + "version": "==2024.8.30" + }, + "charset-normalizer": { + "hashes": [ + "sha256:0099d79bdfcf5c1f0c2c72f91516702ebf8b0b8ddd8905f97a8aecf49712c621", + "sha256:0713f3adb9d03d49d365b70b84775d0a0d18e4ab08d12bc46baa6132ba78aaf6", + "sha256:07afec21bbbbf8a5cc3651aa96b980afe2526e7f048fdfb7f1014d84acc8b6d8", + "sha256:0b309d1747110feb25d7ed6b01afdec269c647d382c857ef4663bbe6ad95a912", + "sha256:0d99dd8ff461990f12d6e42c7347fd9ab2532fb70e9621ba520f9e8637161d7c", + "sha256:0de7b687289d3c1b3e8660d0741874abe7888100efe14bd0f9fd7141bcbda92b", + "sha256:1110e22af8ca26b90bd6364fe4c763329b0ebf1ee213ba32b68c73de5752323d", + "sha256:130272c698667a982a5d0e626851ceff662565379baf0ff2cc58067b81d4f11d", + "sha256:136815f06a3ae311fae551c3df1f998a1ebd01ddd424aa5603a4336997629e95", + "sha256:14215b71a762336254351b00ec720a8e85cada43b987da5a042e4ce3e82bd68e", + "sha256:1db4e7fefefd0f548d73e2e2e041f9df5c59e178b4c72fbac4cc6f535cfb1565", + "sha256:1ffd9493de4c922f2a38c2bf62b831dcec90ac673ed1ca182fe11b4d8e9f2a64", + "sha256:2006769bd1640bdf4d5641c69a3d63b71b81445473cac5ded39740a226fa88ab", + "sha256:20587d20f557fe189b7947d8e7ec5afa110ccf72a3128d61a2a387c3313f46be", + "sha256:223217c3d4f82c3ac5e29032b3f1c2eb0fb591b72161f86d93f5719079dae93e", + "sha256:27623ba66c183eca01bf9ff833875b459cad267aeeb044477fedac35e19ba907", + "sha256:285e96d9d53422efc0d7a17c60e59f37fbf3dfa942073f666db4ac71e8d726d0", + "sha256:2de62e8801ddfff069cd5c504ce3bc9672b23266597d4e4f50eda28846c322f2", + "sha256:2f6c34da58ea9c1a9515621f4d9ac379871a8f21168ba1b5e09d74250de5ad62", + "sha256:309a7de0a0ff3040acaebb35ec45d18db4b28232f21998851cfa709eeff49d62", + "sha256:35c404d74c2926d0287fbd63ed5d27eb911eb9e4a3bb2c6d294f3cfd4a9e0c23", + "sha256:3710a9751938947e6327ea9f3ea6332a09bf0ba0c09cae9cb1f250bd1f1549bc", + "sha256:3d59d125ffbd6d552765510e3f31ed75ebac2c7470c7274195b9161a32350284", + "sha256:40d3ff7fc90b98c637bda91c89d51264a3dcf210cade3a2c6f838c7268d7a4ca", + "sha256:425c5f215d0eecee9a56cdb703203dda90423247421bf0d67125add85d0c4455", + "sha256:43193c5cda5d612f247172016c4bb71251c784d7a4d9314677186a838ad34858", + "sha256:44aeb140295a2f0659e113b31cfe92c9061622cadbc9e2a2f7b8ef6b1e29ef4b", + "sha256:47334db71978b23ebcf3c0f9f5ee98b8d65992b65c9c4f2d34c2eaf5bcaf0594", + "sha256:4796efc4faf6b53a18e3d46343535caed491776a22af773f366534056c4e1fbc", + "sha256:4a51b48f42d9358460b78725283f04bddaf44a9358197b889657deba38f329db", + "sha256:4b67fdab07fdd3c10bb21edab3cbfe8cf5696f453afce75d815d9d7223fbe88b", + "sha256:4ec9dd88a5b71abfc74e9df5ebe7921c35cbb3b641181a531ca65cdb5e8e4dea", + "sha256:4f9fc98dad6c2eaa32fc3af1417d95b5e3d08aff968df0cd320066def971f9a6", + "sha256:54b6a92d009cbe2fb11054ba694bc9e284dad30a26757b1e372a1fdddaf21920", + "sha256:55f56e2ebd4e3bc50442fbc0888c9d8c94e4e06a933804e2af3e89e2f9c1c749", + "sha256:5726cf76c982532c1863fb64d8c6dd0e4c90b6ece9feb06c9f202417a31f7dd7", + "sha256:5d447056e2ca60382d460a604b6302d8db69476fd2015c81e7c35417cfabe4cd", + "sha256:5ed2e36c3e9b4f21dd9422f6893dec0abf2cca553af509b10cd630f878d3eb99", + "sha256:5ff2ed8194587faf56555927b3aa10e6fb69d931e33953943bc4f837dfee2242", + "sha256:62f60aebecfc7f4b82e3f639a7d1433a20ec32824db2199a11ad4f5e146ef5ee", + "sha256:63bc5c4ae26e4bc6be6469943b8253c0fd4e4186c43ad46e713ea61a0ba49129", + "sha256:6b40e8d38afe634559e398cc32b1472f376a4099c75fe6299ae607e404c033b2", + "sha256:6b493a043635eb376e50eedf7818f2f322eabbaa974e948bd8bdd29eb7ef2a51", + "sha256:6dba5d19c4dfab08e58d5b36304b3f92f3bd5d42c1a3fa37b5ba5cdf6dfcbcee", + "sha256:6fd30dc99682dc2c603c2b315bded2799019cea829f8bf57dc6b61efde6611c8", + "sha256:707b82d19e65c9bd28b81dde95249b07bf9f5b90ebe1ef17d9b57473f8a64b7b", + "sha256:7706f5850360ac01d80c89bcef1640683cc12ed87f42579dab6c5d3ed6888613", + "sha256:7782afc9b6b42200f7362858f9e73b1f8316afb276d316336c0ec3bd73312742", + "sha256:79983512b108e4a164b9c8d34de3992f76d48cadc9554c9e60b43f308988aabe", + "sha256:7f683ddc7eedd742e2889d2bfb96d69573fde1d92fcb811979cdb7165bb9c7d3", + "sha256:82357d85de703176b5587dbe6ade8ff67f9f69a41c0733cf2425378b49954de5", + "sha256:84450ba661fb96e9fd67629b93d2941c871ca86fc38d835d19d4225ff946a631", + "sha256:86f4e8cca779080f66ff4f191a685ced73d2f72d50216f7112185dc02b90b9b7", + "sha256:8cda06946eac330cbe6598f77bb54e690b4ca93f593dee1568ad22b04f347c15", + "sha256:8ce7fd6767a1cc5a92a639b391891bf1c268b03ec7e021c7d6d902285259685c", + "sha256:8ff4e7cdfdb1ab5698e675ca622e72d58a6fa2a8aa58195de0c0061288e6e3ea", + "sha256:9289fd5dddcf57bab41d044f1756550f9e7cf0c8e373b8cdf0ce8773dc4bd417", + "sha256:92a7e36b000bf022ef3dbb9c46bfe2d52c047d5e3f3343f43204263c5addc250", + "sha256:92db3c28b5b2a273346bebb24857fda45601aef6ae1c011c0a997106581e8a88", + "sha256:95c3c157765b031331dd4db3c775e58deaee050a3042fcad72cbc4189d7c8dca", + "sha256:980b4f289d1d90ca5efcf07958d3eb38ed9c0b7676bf2831a54d4f66f9c27dfa", + "sha256:9ae4ef0b3f6b41bad6366fb0ea4fc1d7ed051528e113a60fa2a65a9abb5b1d99", + "sha256:9c98230f5042f4945f957d006edccc2af1e03ed5e37ce7c373f00a5a4daa6149", + "sha256:9fa2566ca27d67c86569e8c85297aaf413ffab85a8960500f12ea34ff98e4c41", + "sha256:a14969b8691f7998e74663b77b4c36c0337cb1df552da83d5c9004a93afdb574", + "sha256:a8aacce6e2e1edcb6ac625fb0f8c3a9570ccc7bfba1f63419b3769ccf6a00ed0", + "sha256:a8e538f46104c815be19c975572d74afb53f29650ea2025bbfaef359d2de2f7f", + "sha256:aa41e526a5d4a9dfcfbab0716c7e8a1b215abd3f3df5a45cf18a12721d31cb5d", + "sha256:aa693779a8b50cd97570e5a0f343538a8dbd3e496fa5dcb87e29406ad0299654", + "sha256:ab22fbd9765e6954bc0bcff24c25ff71dcbfdb185fcdaca49e81bac68fe724d3", + "sha256:ab2e5bef076f5a235c3774b4f4028a680432cded7cad37bba0fd90d64b187d19", + "sha256:ab973df98fc99ab39080bfb0eb3a925181454d7c3ac8a1e695fddfae696d9e90", + "sha256:af73657b7a68211996527dbfeffbb0864e043d270580c5aef06dc4b659a4b578", + "sha256:b197e7094f232959f8f20541ead1d9862ac5ebea1d58e9849c1bf979255dfac9", + "sha256:b295729485b06c1a0683af02a9e42d2caa9db04a373dc38a6a58cdd1e8abddf1", + "sha256:b8831399554b92b72af5932cdbbd4ddc55c55f631bb13ff8fe4e6536a06c5c51", + "sha256:b8dcd239c743aa2f9c22ce674a145e0a25cb1566c495928440a181ca1ccf6719", + "sha256:bcb4f8ea87d03bc51ad04add8ceaf9b0f085ac045ab4d74e73bbc2dc033f0236", + "sha256:bd7af3717683bea4c87acd8c0d3d5b44d56120b26fd3f8a692bdd2d5260c620a", + "sha256:bf4475b82be41b07cc5e5ff94810e6a01f276e37c2d55571e3fe175e467a1a1c", + "sha256:c3e446d253bd88f6377260d07c895816ebf33ffffd56c1c792b13bff9c3e1ade", + "sha256:c57516e58fd17d03ebe67e181a4e4e2ccab1168f8c2976c6a334d4f819fe5944", + "sha256:c94057af19bc953643a33581844649a7fdab902624d2eb739738a30e2b3e60fc", + "sha256:cab5d0b79d987c67f3b9e9c53f54a61360422a5a0bc075f43cab5621d530c3b6", + "sha256:ce031db0408e487fd2775d745ce30a7cd2923667cf3b69d48d219f1d8f5ddeb6", + "sha256:cee4373f4d3ad28f1ab6290684d8e2ebdb9e7a1b74fdc39e4c211995f77bec27", + "sha256:d5b054862739d276e09928de37c79ddeec42a6e1bfc55863be96a36ba22926f6", + "sha256:dbe03226baf438ac4fda9e2d0715022fd579cb641c4cf639fa40d53b2fe6f3e2", + "sha256:dc15e99b2d8a656f8e666854404f1ba54765871104e50c8e9813af8a7db07f12", + "sha256:dcaf7c1524c0542ee2fc82cc8ec337f7a9f7edee2532421ab200d2b920fc97cf", + "sha256:dd4eda173a9fcccb5f2e2bd2a9f423d180194b1bf17cf59e3269899235b2a114", + "sha256:dd9a8bd8900e65504a305bf8ae6fa9fbc66de94178c420791d0293702fce2df7", + "sha256:de7376c29d95d6719048c194a9cf1a1b0393fbe8488a22008610b0361d834ecf", + "sha256:e7fdd52961feb4c96507aa649550ec2a0d527c086d284749b2f582f2d40a2e0d", + "sha256:e91f541a85298cf35433bf66f3fab2a4a2cff05c127eeca4af174f6d497f0d4b", + "sha256:e9e3c4c9e1ed40ea53acf11e2a386383c3304212c965773704e4603d589343ed", + "sha256:ee803480535c44e7f5ad00788526da7d85525cfefaf8acf8ab9a310000be4b03", + "sha256:f09cb5a7bbe1ecae6e87901a2eb23e0256bb524a79ccc53eb0b7629fbe7677c4", + "sha256:f19c1585933c82098c2a520f8ec1227f20e339e33aca8fa6f956f6691b784e67", + "sha256:f1a2f519ae173b5b6a2c9d5fa3116ce16e48b3462c8b96dfdded11055e3d6365", + "sha256:f28f891ccd15c514a0981f3b9db9aa23d62fe1a99997512b0491d2ed323d229a", + "sha256:f3e73a4255342d4eb26ef6df01e3962e73aa29baa3124a8e824c5d3364a65748", + "sha256:f606a1881d2663630ea5b8ce2efe2111740df4b687bd78b34a8131baa007f79b", + "sha256:fe9f97feb71aa9896b81973a7bbada8c49501dc73e58a10fcef6663af95e5079", + "sha256:ffc519621dce0c767e96b9c53f09c5d215578e10b02c285809f76509a3931482" + ], + "markers": "python_full_version >= '3.7.0'", + "version": "==3.4.0" + }, + "idna": { + "hashes": [ + "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9", + "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3" + ], + "markers": "python_version >= '3.6'", + "version": "==3.10" + }, + "pycairo": { + "hashes": [ + "sha256:01505c138a313df2469f812405963532fc2511fb9bca9bdc8e0ab94c55d1ced8", + "sha256:03bf570e3919901572987bc69237b648fe0de242439980be3e606b396e3318c9", + "sha256:1b1321652a6e27c4de3069709b1cae22aed2707fd8c5e889c04a95669228af2a", + "sha256:27cb4d3a80e3b9990af552818515a8e466e0317063a6e61585533f1a86f1b7d5", + "sha256:5cb21e7a00a2afcafea7f14390235be33497a2cce53a98a19389492a60628430", + "sha256:9a9b79f92a434dae65c34c830bb9abdbd92654195e73d52663cbe45af1ad14b2", + "sha256:b0349d744c068b6644ae23da6ada111c8a8a7e323b56cbce3707cba5bdb474cc", + "sha256:d40a6d80b15dacb3672dc454df4bc4ab3988c6b3f36353b24a255dc59a1c8aea", + "sha256:e20f431244634cf244ab6b4c3a2e540e65746eed1324573cf291981c3e65fc05", + "sha256:e2239b9bb6c05edae5f3be97128e85147a155465e644f4d98ea0ceac7afc04ee", + "sha256:f9ca8430751f1fdcd3f072377560c9e15608b9a42d61375469db853566993c9b" + ], + "markers": "python_version >= '3.9'", + "version": "==1.27.0" + }, + "pygobject": { + "hashes": [ + "sha256:4500ad3dbf331773d8dedf7212544c999a76fc96b63a91b3dcac1e5925a1d103" + ], + "index": "pypi", + "markers": "python_version >= '3.9' and python_version < '4.0'", + "version": "==3.50.0" + }, + "requests": { + "hashes": [ + "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760", + "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6" + ], + "index": "pypi", + "markers": "python_version >= '3.8'", + "version": "==2.32.3" + }, + "urllib3": { + "hashes": [ + "sha256:ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac", + "sha256:e7d814a81dad81e6caf2ec9fdedb284ecc9c73076b62654547cc64ccdcae26e9" + ], + "markers": "python_version >= '3.8'", + "version": "==2.2.3" + }, + "vdf": { + "hashes": [ + "sha256:68c1a125cc49e343d535af2dd25074e9cb0908c6607f073947c4a04bbe234534", + "sha256:fd5419f41e07a1009e5ffd027c7dcbe43d1f7e8ef453aeaa90d9d04b807de2af" + ], + "index": "pypi", + "version": "==3.4" + } + }, + "develop": { + "astroid": { + "hashes": [ + "sha256:5cfc40ae9f68311075d27ef68a4841bdc5cc7f6cf86671b49f00607d30188e2d", + "sha256:a9d1c946ada25098d790e079ba2a1b112157278f3fb7e718ae6a9252f5835dc8" + ], + "markers": "python_full_version >= '3.9.0'", + "version": "==3.3.5" + }, + "black": { + "hashes": [ + "sha256:14b3502784f09ce2443830e3133dacf2c0110d45191ed470ecb04d0f5f6fcb0f", + "sha256:17374989640fbca88b6a448129cd1745c5eb8d9547b464f281b251dd00155ccd", + "sha256:1c536fcf674217e87b8cc3657b81809d3c085d7bf3ef262ead700da345bfa6ea", + "sha256:1cbacacb19e922a1d75ef2b6ccaefcd6e93a2c05ede32f06a21386a04cedb981", + "sha256:1f93102e0c5bb3907451063e08b9876dbeac810e7da5a8bfb7aeb5a9ef89066b", + "sha256:2cd9c95431d94adc56600710f8813ee27eea544dd118d45896bb734e9d7a0dc7", + "sha256:30d2c30dc5139211dda799758559d1b049f7f14c580c409d6ad925b74a4208a8", + "sha256:394d4ddc64782e51153eadcaaca95144ac4c35e27ef9b0a42e121ae7e57a9175", + "sha256:3bb2b7a1f7b685f85b11fed1ef10f8a9148bceb49853e47a294a3dd963c1dd7d", + "sha256:4007b1393d902b48b36958a216c20c4482f601569d19ed1df294a496eb366392", + "sha256:5a2221696a8224e335c28816a9d331a6c2ae15a2ee34ec857dcf3e45dbfa99ad", + "sha256:63f626344343083322233f175aaf372d326de8436f5928c042639a4afbbf1d3f", + "sha256:649fff99a20bd06c6f727d2a27f401331dc0cc861fb69cde910fe95b01b5928f", + "sha256:680359d932801c76d2e9c9068d05c6b107f2584b2a5b88831c83962eb9984c1b", + "sha256:846ea64c97afe3bc677b761787993be4991810ecc7a4a937816dd6bddedc4875", + "sha256:b5e39e0fae001df40f95bd8cc36b9165c5e2ea88900167bddf258bacef9bbdc3", + "sha256:ccfa1d0cb6200857f1923b602f978386a3a2758a65b52e0950299ea014be6800", + "sha256:d37d422772111794b26757c5b55a3eade028aa3fde43121ab7b673d050949d65", + "sha256:ddacb691cdcdf77b96f549cf9591701d8db36b2f19519373d60d31746068dbf2", + "sha256:e6668650ea4b685440857138e5fe40cde4d652633b1bdffc62933d0db4ed9812", + "sha256:f9da3333530dbcecc1be13e69c250ed8dfa67f43c4005fb537bb426e19200d50", + "sha256:fe4d6476887de70546212c99ac9bd803d90b42fc4767f058a0baa895013fbb3e" + ], + "index": "pypi", + "markers": "python_version >= '3.9'", + "version": "==24.10.0" + }, + "click": { + "hashes": [ + "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28", + "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de" + ], + "markers": "python_version >= '3.7'", + "version": "==8.1.7" + }, + "dill": { + "hashes": [ + "sha256:468dff3b89520b474c0397703366b7b95eebe6303f108adf9b19da1f702be87a", + "sha256:81aa267dddf68cbfe8029c42ca9ec6a4ab3b22371d1c450abc54422577b4512c" + ], + "markers": "python_version >= '3.11'", + "version": "==0.3.9" + }, + "flake8": { + "hashes": [ + "sha256:049d058491e228e03e67b390f311bbf88fce2dbaa8fa673e7aea87b7198b8d38", + "sha256:597477df7860daa5aa0fdd84bf5208a043ab96b8e96ab708770ae0364dd03213" + ], + "markers": "python_full_version >= '3.8.1'", + "version": "==7.1.1" + }, + "flake8-for-pycharm": { + "hashes": [ + "sha256:d4c642daa70afb1a24af958500699e28579a47ae7d0bbcc2290cf799157877ae", + "sha256:ec0f3aa95d3f0cc7a9e7bad1d16e56862909a8d03a14047cf93bf1c1e0a2e2bc" + ], + "index": "pypi", + "markers": "python_version >= '3.4'", + "version": "==0.4.1" + }, + "isort": { + "hashes": [ + "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109", + "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6" + ], + "markers": "python_full_version >= '3.8.0'", + "version": "==5.13.2" + }, + "mccabe": { + "hashes": [ + "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325", + "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e" + ], + "markers": "python_version >= '3.6'", + "version": "==0.7.0" + }, + "mypy-extensions": { + "hashes": [ + "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d", + "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782" + ], + "markers": "python_version >= '3.5'", + "version": "==1.0.0" + }, + "packaging": { + "hashes": [ + "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759", + "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f" + ], + "markers": "python_version >= '3.8'", + "version": "==24.2" + }, + "pathspec": { + "hashes": [ + "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08", + "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712" + ], + "markers": "python_version >= '3.8'", + "version": "==0.12.1" + }, + "platformdirs": { + "hashes": [ + "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907", + "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb" + ], + "markers": "python_version >= '3.8'", + "version": "==4.3.6" + }, + "pycodestyle": { + "hashes": [ + "sha256:46f0fb92069a7c28ab7bb558f05bfc0110dac69a0cd23c61ea0040283a9d78b3", + "sha256:6838eae08bbce4f6accd5d5572075c63626a15ee3e6f842df996bf62f6d73521" + ], + "markers": "python_version >= '3.8'", + "version": "==2.12.1" + }, + "pyflakes": { + "hashes": [ + "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f", + "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a" + ], + "markers": "python_version >= '3.8'", + "version": "==3.2.0" + }, + "pylint": { + "hashes": [ + "sha256:2f846a466dd023513240bc140ad2dd73bfc080a5d85a710afdb728c420a5a2b9", + "sha256:9f3dcc87b1203e612b78d91a896407787e708b3f189b5fa0b307712d49ff0c6e" + ], + "markers": "python_full_version >= '3.9.0'", + "version": "==3.3.1" + }, + "tomlkit": { + "hashes": [ + "sha256:7a974427f6e119197f670fbbbeae7bef749a6c14e793db934baefc1b5f03efde", + "sha256:fff5fe59a87295b278abd31bec92c15d9bc4a06885ab12bcea52c71119392e79" + ], + "markers": "python_version >= '3.8'", + "version": "==0.13.2" + } + } +} diff --git a/sif.py b/sif.py index eee1adf..a053ff6 100755 --- a/sif.py +++ b/sif.py @@ -61,9 +61,7 @@ def get_steam_libraries(): libraries = get_from_dict(libraries_config, ["LibraryFolders"], {}) if not libraries: - print_warning( - "[error] No LibraryFolders key found in %s" % LIBRARY_FOLDERS_FILE - ) + print_warning("[error] No LibraryFolders key found in %s" % LIBRARY_FOLDERS_FILE) exit(1) for library in libraries.values(): @@ -164,11 +162,7 @@ def get_all_games_from_theme(): """Returns list of APP_IDs of Steam games that have icon in system icon theme.""" sample_icon = get_icon_path("nautilus") icon_theme_path = sample_icon[: -len(sample_icon.split("/")[-1])] - games = [ - i.replace("_", ".").split(".")[2] - for i in next(os.walk(icon_theme_path))[2] - if "steam_icon" in i - ] + games = [i.replace("_", ".").split(".")[2] for i in next(os.walk(icon_theme_path))[2] if "steam_icon" in i] return sorted(games, key=lambda item: int(item)) @@ -197,9 +191,7 @@ def fix_launch_option(app_id, wm_name, wm_name_alt=""): for conf_file in localconfig_paths: loaded = vdf.load(open(conf_file)) - steam = get_from_dict( - loaded, ["UserLocalConfigStore", "Software", "Valve", "Steam"], {} - ) + steam = get_from_dict(loaded, ["UserLocalConfigStore", "Software", "Valve", "Steam"], {}) apps = get_from_dict(steam, ["Apps"], {}) if not apps: @@ -210,9 +202,7 @@ def fix_launch_option(app_id, wm_name, wm_name_alt=""): app = apps[app_id] if "LaunchOptions" not in app.keys(): app["LaunchOptions"] = "" - app["LaunchOptions"] = sub( - "&\\s/.*fix-wm-class\\.sh.*?;", "", app["LaunchOptions"] - ) + app["LaunchOptions"] = sub("&\\s/.*fix-wm-class\\.sh.*?;", "", app["LaunchOptions"]) script = str(WM_CLASS_FIXER_SCRIPT) if wm_name_alt: app["LaunchOptions"] += '& %s "%s" "%s";' % ( @@ -230,9 +220,7 @@ def restore_launch_options(): for conf_file in localconfig_paths: loaded = vdf.load(open(conf_file)) - steam = get_from_dict( - loaded, ["UserLocalConfigStore", "Software", "Valve", "Steam"], {} - ) + steam = get_from_dict(loaded, ["UserLocalConfigStore", "Software", "Valve", "Steam"], {}) apps = get_from_dict(steam, ["Apps"], {}) if not apps: @@ -241,9 +229,7 @@ def restore_launch_options(): for app_id in apps.keys(): app = apps[app_id] if "LaunchOptions" in app.keys(): - app["LaunchOptions"] = sub( - "&\\s/.*fix-wm-class\\.sh.*?;", "", app["LaunchOptions"] - ) + app["LaunchOptions"] = sub("&\\s/.*fix-wm-class\\.sh.*?;", "", app["LaunchOptions"]) vdf.dump(loaded, open(conf_file, "w"), pretty=True) @@ -462,16 +448,12 @@ def quit_handler(_, __): if options.browse: print("These Steam games have icon in %s icon theme:" % GTK_THEME) - print( - "(Fetching names from https://store.steampowered.com/api. This may take a while.)\n" - ) + print("(Fetching names from https://store.steampowered.com/api. This may take a while.)\n") for game in get_all_games_from_theme(): name = get_game_name(fetch_json(game)) if options.verbose: desktop = HIDDEN_DESKTOP_FILES_DIR + "/" + name + ".desktop" - print( - "%7s - %s (%s)" % (game, name, get_icon_path("steam_icon_" + game)) - ) + print("%7s - %s (%s)" % (game, name, get_icon_path("steam_icon_" + game))) else: print("%7s - %s" % (game, name)) quit() @@ -519,9 +501,7 @@ def quit_handler(_, __): ids = next(os.walk(STEAM_INSTALL_DIR + "/userdata"))[1] if len(ids) > 0: for folder in ids: - vdf_file = ( - STEAM_INSTALL_DIR + "/userdata/" + folder + "/config/localconfig.vdf" - ) + vdf_file = STEAM_INSTALL_DIR + "/userdata/" + folder + "/config/localconfig.vdf" if os.path.isfile(vdf_file): localconfig_paths.append(vdf_file) if len(localconfig_paths) > 0: @@ -544,9 +524,7 @@ def quit_handler(_, __): os.rmdir(HIDDEN_DESKTOP_FILES_DIR) print("\nDirectory %s removed." % HIDDEN_DESKTOP_FILES_DIR) else: - print( - "Couldn't restore default launch options. Exit Steam and try it again." - ) + print("Couldn't restore default launch options. Exit Steam and try it again.") quit() update_desktop_database() else: @@ -554,10 +532,7 @@ def quit_handler(_, __): quit() raw_installed_games = get_installed_games(library_folders).items() - installed_games = { - key: val - for key, val in sorted(raw_installed_games, key=lambda item: int(item[0])) - } + installed_games = {key: val for key, val in sorted(raw_installed_games, key=lambda item: int(item[0]))} fixable_games = get_fixable_games(installed_games) # --games @@ -590,22 +565,15 @@ def quit_handler(_, __): for game in games_with_compat: game_dict = games_with_compat[game] if game in fixable_games: - verbose_print( - " - %s - %s" - % (fixable_games[game], get_from_dict(game_dict, ["Name"])) - ) - if any( - x in get_from_dict(game_dict, ["Name"], []) for x in ["proton", "Proton"] - ): + verbose_print(" - %s - %s" % (fixable_games[game], get_from_dict(game_dict, ["Name"]))) + if any(x in get_from_dict(game_dict, ["Name"], []) for x in ["proton", "Proton"]): proton_games.append(game) verbose_print("") # --icons if options.icons: - print( - f"These icons for your installed Steam games were found in {GTK_THEME} icon theme:\n" - ) + print(f"These icons for your installed Steam games were found in {GTK_THEME} icon theme:\n") margin = 0 for name in fixable_games.values(): if len(name) > margin: @@ -617,9 +585,7 @@ def quit_handler(_, __): symbol = "*" elif key in database["wm_names"]: symbol = "~" - print( - f"{symbol} {Colors.BOLD}{fixable_games[key]:<{margin}}{Colors.END} - {icon_path}" - ) + print(f"{symbol} {Colors.BOLD}{fixable_games[key]:<{margin}}{Colors.END} - {icon_path}") print("\n* - game is in our database and can be fixed") print("~ - script will edit launch options of the game") quit() @@ -642,9 +608,7 @@ def quit_handler(_, __): if options.single: if options.single in fixable_games: - fixable_games = { - k: v for k, v in fixable_games.items() if k == options.single - } + fixable_games = {k: v for k, v in fixable_games.items() if k == options.single} if not fixable_games: print_warning("No games found to fix.") @@ -719,9 +683,7 @@ def quit_handler(_, __): game_wm_class = record.split("=")[0] game_name = record.split("=")[1] or fixable_games[game] file_name = game_wm_class.replace(" ", "-") - try_to_create_desktop_file( - file_name, game_name, game, game_wm_class - ) + try_to_create_desktop_file(file_name, game_name, game, game_wm_class) else: try_to_create_desktop_file(file_name, game_name, game, wm_classes[game]) @@ -751,9 +713,7 @@ def quit_handler(_, __): if launch_option_counter > 0: if steam_detected: - print_warning( - "\nSome games couldn't be fixed due to running Steam.\nExit Steam and try it again." - ) + print_warning("\nSome games couldn't be fixed due to running Steam.\nExit Steam and try it again.") else: print("\n * - added fix to game launch options") diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..da88414 --- /dev/null +++ b/tests.py @@ -0,0 +1,27 @@ +import json +import unittest + +DATABASE_FILE = "database.json" + + +class DatabaseValidity(unittest.TestCase): + with open(DATABASE_FILE) as json_file: + database = json.load(json_file) + + def test_database_structure(self): + self.assertEqual(self.database.keys(), {"wm_classes", "wm_names"}) + + def test_database_sorted(self): + keys = list(map(lambda x: int(x), self.database["wm_classes"].keys())) + sorted_keys = sorted(keys) + + self.assertEqual(keys, sorted_keys) + + keys = list(map(lambda x: int(x), self.database["wm_names"].keys())) + sorted_keys = sorted(keys) + + self.assertEqual(keys, sorted_keys) + + +if __name__ == "__main__": + unittest.main() From b98d5a574334dcd44f7a69ffea952db8601d1a4f Mon Sep 17 00:00:00 2001 From: BlueManCZ Date: Tue, 12 Nov 2024 12:16:33 +0100 Subject: [PATCH 2/2] Add libgirepository1.0-dev dependency --- .github/workflows/actions.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index f3a4236..45e5758 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -16,6 +16,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | + sudo apt-get install libgirepository1.0-dev python -m pip install --upgrade pip pip install pipenv pipenv install --dev