Skip to content

Commit

Permalink
Restore lost changes from #540 (#590)
Browse files Browse the repository at this point in the history
When I was working on the last release I had got myself into a mixed-up
state with too many unexpectedly-changed files. It was easiest to
restore files rather than edit them and I lost the changes in this PR.
These were from an external contributor in PR #540.
  • Loading branch information
stevemessick authored Jun 12, 2024
1 parent ee2f573 commit 49bbf9b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
13 changes: 11 additions & 2 deletions kaggle/api/kaggle_api_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,17 @@ class KaggleApi(KaggleApi):
MAX_NUM_INBOX_FILES_TO_UPLOAD = 1000
MAX_UPLOAD_RESUME_ATTEMPTS = 10

config_dir = os.environ.get('KAGGLE_CONFIG_DIR') or os.path.join(
expanduser('~'), '.kaggle')
config_dir = os.environ.get('KAGGLE_CONFIG_DIR')

if not config_dir:
config_dir = os.path.join(expanduser('~'), '.kaggle')
# Use ~/.kaggle if it already exists for backwards compatibility,
# otherwise follow XDG base directory specification
if sys.platform.startswith('linux') and not os.path.exists(config_dir):
config_dir = os.path.join(
(os.environ.get('XDG_CONFIG_HOME')
or os.path.join(expanduser('~'), '.config')), 'kaggle')

if not os.path.exists(config_dir):
os.makedirs(config_dir)

Expand Down
2 changes: 1 addition & 1 deletion kaggle/test/test_authenticate.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_environment_variables(self):
def test_config_actions(self):
api = KaggleApi()

self.assertTrue(api.config_dir.endswith('.kaggle'))
self.assertTrue(api.config_dir.endswith('kaggle'))
self.assertEqual(api.get_config_value('doesntexist'), None)


Expand Down
13 changes: 11 additions & 2 deletions src/kaggle/api/kaggle_api_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,17 @@ class KaggleApi(KaggleApi):
MAX_NUM_INBOX_FILES_TO_UPLOAD = 1000
MAX_UPLOAD_RESUME_ATTEMPTS = 10

config_dir = os.environ.get('KAGGLE_CONFIG_DIR') or os.path.join(
expanduser('~'), '.kaggle')
config_dir = os.environ.get('KAGGLE_CONFIG_DIR')

if not config_dir:
config_dir = os.path.join(expanduser('~'), '.kaggle')
# Use ~/.kaggle if it already exists for backwards compatibility,
# otherwise follow XDG base directory specification
if sys.platform.startswith('linux') and not os.path.exists(config_dir):
config_dir = os.path.join(
(os.environ.get('XDG_CONFIG_HOME')
or os.path.join(expanduser('~'), '.config')), 'kaggle')

if not os.path.exists(config_dir):
os.makedirs(config_dir)

Expand Down
2 changes: 1 addition & 1 deletion src/kaggle/test/test_authenticate.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_environment_variables(self):
def test_config_actions(self):
api = KaggleApi()

self.assertTrue(api.config_dir.endswith('.kaggle'))
self.assertTrue(api.config_dir.endswith('kaggle'))
self.assertEqual(api.get_config_value('doesntexist'), None)


Expand Down

0 comments on commit 49bbf9b

Please sign in to comment.