-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
copy config and directory and load dynamically
- Loading branch information
1 parent
f657788
commit fe1960e
Showing
2 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
|
||
def copy_conf(): | ||
""" | ||
Copy the configuration file to the user's home directory. | ||
""" | ||
import os | ||
import shutil | ||
from . import __file__ as root | ||
|
||
root = os.path.dirname(root) | ||
conf = os.path.join(root, 'config.yaml') | ||
home = os.path.expanduser('~') | ||
dest = os.path.join(home, '.config', 'shelfslide', 'config.yaml') | ||
|
||
if not os.path.exists(os.path.dirname(dest)): | ||
os.makedirs(os.path.dirname(dest)) | ||
|
||
shutil.copy(conf, dest) | ||
print("Configuration file copied to {}".format(dest)) | ||
|
||
def copy_books_dir(): | ||
""" | ||
Copy the books directory to the user's home directory. | ||
""" | ||
import os | ||
import shutil | ||
from . import __file__ as root | ||
|
||
root = os.path.dirname(root) | ||
books = os.path.join(root, 'books') | ||
home = os.path.expanduser('~') | ||
dest = os.path.join(home, '.config', 'shelfslide', 'books') | ||
|
||
if not os.path.exists(os.path.dirname(dest)): | ||
os.makedirs(os.path.dirname(dest)) | ||
|
||
shutil.copytree(books, dest) | ||
print("Books directory copied to {}".format(dest)) |