Skip to content

Commit 1e14734

Browse files
Add code
1 parent 9280b85 commit 1e14734

File tree

10 files changed

+352
-0
lines changed

10 files changed

+352
-0
lines changed

.gitignore

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
### Custom ###
2+
3+
.idea/chdir.iml
4+
.idea/misc.xml
5+
.vscode/
6+
**.swp
7+
8+
# Created by https://www.gitignore.io/api/pycharm,python
9+
# Edit at https://www.gitignore.io/?templates=pycharm,python
10+
11+
### PyCharm ###
12+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
13+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
14+
15+
# User-specific stuff
16+
.idea/**/workspace.xml
17+
.idea/**/tasks.xml
18+
.idea/**/usage.statistics.xml
19+
.idea/**/dictionaries
20+
.idea/**/shelf
21+
22+
# Generated files
23+
.idea/**/contentModel.xml
24+
25+
# Sensitive or high-churn files
26+
.idea/**/dataSources/
27+
.idea/**/dataSources.ids
28+
.idea/**/dataSources.local.xml
29+
.idea/**/sqlDataSources.xml
30+
.idea/**/dynamic.xml
31+
.idea/**/uiDesigner.xml
32+
.idea/**/dbnavigator.xml
33+
34+
# Gradle
35+
.idea/**/gradle.xml
36+
.idea/**/libraries
37+
38+
# Gradle and Maven with auto-import
39+
# When using Gradle or Maven with auto-import, you should exclude module files,
40+
# since they will be recreated, and may cause churn. Uncomment if using
41+
# auto-import.
42+
# .idea/modules.xml
43+
# .idea/*.iml
44+
# .idea/modules
45+
# *.iml
46+
# *.ipr
47+
48+
# CMake
49+
cmake-build-*/
50+
51+
# Mongo Explorer plugin
52+
.idea/**/mongoSettings.xml
53+
54+
# File-based project format
55+
*.iws
56+
57+
# IntelliJ
58+
out/
59+
60+
# mpeltonen/sbt-idea plugin
61+
.idea_modules/
62+
63+
# JIRA plugin
64+
atlassian-ide-plugin.xml
65+
66+
# Cursive Clojure plugin
67+
.idea/replstate.xml
68+
69+
# Crashlytics plugin (for Android Studio and IntelliJ)
70+
com_crashlytics_export_strings.xml
71+
crashlytics.properties
72+
crashlytics-build.properties
73+
fabric.properties
74+
75+
# Editor-based Rest Client
76+
.idea/httpRequests
77+
78+
# Android studio 3.1+ serialized cache file
79+
.idea/caches/build_file_checksums.ser
80+
81+
### PyCharm Patch ###
82+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
83+
84+
# *.iml
85+
# modules.xml
86+
# .idea/misc.xml
87+
# *.ipr
88+
89+
# Sonarlint plugin
90+
.idea/**/sonarlint/
91+
92+
# SonarQube Plugin
93+
.idea/**/sonarIssues.xml
94+
95+
# Markdown Navigator plugin
96+
.idea/**/markdown-navigator.xml
97+
.idea/**/markdown-navigator/
98+
99+
### Python ###
100+
# Byte-compiled / optimized / DLL files
101+
__pycache__/
102+
*.py[cod]
103+
*$py.class
104+
105+
# C extensions
106+
*.so
107+
108+
# Distribution / packaging
109+
.Python
110+
build/
111+
develop-eggs/
112+
dist/
113+
downloads/
114+
eggs/
115+
.eggs/
116+
lib/
117+
lib64/
118+
parts/
119+
sdist/
120+
var/
121+
wheels/
122+
pip-wheel-metadata/
123+
share/python-wheels/
124+
*.egg-info/
125+
.installed.cfg
126+
*.egg
127+
MANIFEST
128+
129+
# PyInstaller
130+
# Usually these files are written by a python script from a template
131+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
132+
*.manifest
133+
*.spec
134+
135+
# Installer logs
136+
pip-log.txt
137+
pip-delete-this-directory.txt
138+
139+
# Unit test / coverage reports
140+
htmlcov/
141+
.tox/
142+
.nox/
143+
.coverage
144+
.coverage.*
145+
.cache
146+
nosetests.xml
147+
coverage.xml
148+
*.cover
149+
.hypothesis/
150+
.pytest_cache/
151+
152+
# Translations
153+
*.mo
154+
*.pot
155+
156+
# Scrapy stuff:
157+
.scrapy
158+
159+
# Sphinx documentation
160+
docs/_build/
161+
162+
# PyBuilder
163+
target/
164+
165+
# pyenv
166+
.python-version
167+
168+
# pipenv
169+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
170+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
171+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
172+
# install all needed dependencies.
173+
#Pipfile.lock
174+
175+
# celery beat schedule file
176+
celerybeat-schedule
177+
178+
# SageMath parsed files
179+
*.sage.py
180+
181+
# Spyder project settings
182+
.spyderproject
183+
.spyproject
184+
185+
# Rope project settings
186+
.ropeproject
187+
188+
# Mr Developer
189+
.mr.developer.cfg
190+
.project
191+
.pydevproject
192+
193+
# mkdocs documentation
194+
/site
195+
196+
# mypy
197+
.mypy_cache/
198+
.dmypy.json
199+
dmypy.json
200+
201+
# Pyre type checker
202+
.pyre/
203+
204+
# End of https://www.gitignore.io/api/pycharm,python

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/MIT.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/profiles_settings.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chdir/__init__.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2020 Sam McCormack
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
__version__ = "1.0.0"
24+
25+
26+
def here(path: str) -> None:
27+
"""
28+
Call this function with `__file__` to set the current working directory to the location of the current Python file.
29+
30+
Parameters
31+
----------
32+
path : str
33+
The path to set the working directory to.
34+
35+
Pass `__file__` to set the working directory to the location of the current Python file.
36+
"""
37+
import os
38+
from os.path import abspath, dirname
39+
40+
os.chdir(dirname(abspath(path)))

setup.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2020 Sam McCormack
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
import re
23+
from os import path
24+
25+
from setuptools import setup
26+
27+
here = path.dirname(path.abspath(__file__))
28+
29+
with open("chdir/__init__.py") as f:
30+
regexp = re.compile(r"[0-9]+\.[0-9]+\.[0-9]+")
31+
version = regexp.findall(f.read())[0]
32+
33+
with open(path.join(here, "README.md"), encoding="utf-8") as f:
34+
long_description = f.read()
35+
36+
setup(
37+
name="chdir",
38+
version=version,
39+
packages=["chdir"],
40+
python_requires="~=3.6",
41+
description="Tiny library for setting the working directory to the location of a Python script.",
42+
long_description=long_description,
43+
long_description_content_type="text/markdown",
44+
url="https://github.com/CabbageDevelopment/chdir",
45+
author="Sam McCormack",
46+
author_email="cabbagedevelopment@gmail.com",
47+
classifiers=[
48+
"Intended Audience :: Developers",
49+
"License :: OSI Approved :: MIT License",
50+
"Programming Language :: Python :: 3.6",
51+
"Programming Language :: Python :: 3.7",
52+
"Programming Language :: Python :: 3.8",
53+
],
54+
project_urls={
55+
"Source": "https://github.com/CabbageDevelopment/chdir"
56+
},
57+
)

0 commit comments

Comments
 (0)