Skip to content

Commit

Permalink
Fixed issue with execution of the main script from an external curren…
Browse files Browse the repository at this point in the history
…t work directory.
  • Loading branch information
KuYaki committed Oct 5, 2020
1 parent 5086085 commit 9b2b12b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This project was developed to avoid problems with gitmodules importing in Python projects.

## Dependencies
This project has no any dependencies, it uses only 'os' and 'sys' standard libraries.
This project has no any dependencies, it uses only <b>os</b> and <b>sys</b> standard libraries.

## Usage
Install this project via PyPi:
Expand All @@ -20,9 +20,7 @@ import my_git_submodule_2
```

## Example
Here is an example repository with a problem explanation in its readme.

https://github.com/KuYaki/gitmodules_example_a
Here is an <a href=https://github.com/KuYaki/gitmodules_example_a>example</a> with a problem explanation in its readme.

## How does it work
Right while importing this module tries to find .gitmodules file in your project,
Expand All @@ -33,7 +31,7 @@ After what it recursively repeat this action for all the git submodules.
This module doesn't change current work directory, so that if some submodule
was assumed to work with its root folder via current work directory it will fail.

You don't need to call any functions from the 'gitmodules' to make it work and it may call
You don't need to call any functions from the <b>gitmodules</b> to make it work and it may call
'Unused import statement' code violation. To avoid it, add next comment in front of this import:

```python
Expand Down
2 changes: 1 addition & 1 deletion gitmodules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__credits__ = ['kuyaki']
__maintainer__ = 'kuyaki'
__date__ = '2020/10/02'
__version__ = '0.0.3'
__version__ = '0.0.4'

from gitmodules.gitmodules import extend_paths

Expand Down
4 changes: 3 additions & 1 deletion gitmodules/gitmodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
import os


def extend_paths(cwd="."):
def extend_paths(cwd=None):
"""
This function tries to find .gitmodules file in your project,
parse it and append all the git submodules directories to the 'sys.path'.
After what it recursively repeat this action for all the git submodules.
:param cwd: current work directory where the '.gitmodules' file should be placed
:return: None
"""
if cwd is None:
cwd = sys.path[0]
git_modules_file_path = os.path.join(cwd, ".gitmodules")
if os.path.exists(git_modules_file_path):
with open(git_modules_file_path) as f:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
author=gitmodules.__author__,
author_email='[email protected]',
url='https://github.com/kuyaki/gitmodules',
download_url='https://github.com/kuyaki/gitmodules/archive/v0.0.3.tar.gz',
download_url='https://github.com/kuyaki/gitmodules/archive/v0.0.4.tar.gz',
keywords=['git', 'submodules', 'submodule', 'module', 'gitmodules', 'gitmodule', 'python', 'import'],
classifiers=[
'Development Status :: 3 - Alpha', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable"
Expand Down

0 comments on commit 9b2b12b

Please sign in to comment.