Skip to content

Commit

Permalink
new: Create conf.yml.exmaple if does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
at-wr committed Aug 20, 2023
1 parent 028380f commit dd62684
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ Also, this requires ```$wgAllowCopyUploads = true;``` in the wiki's local settin

1. Download the latest build version from [here](https://github.com/AlanYe-Dev/mediawiki-file-import-utility/actions/workflows/pyinstaller-windows.yml).
2. Duplicate ```conf.yml.example```, rename it to ```conf.yml```.
3. Fill in the Bot credentials previous fetched.
4. Optional: Prepare a list of import filename to ```import.txt```.
5. Run **main.exe**.
3. Fill in the Bot credentials previous fetched. Example:
```
bot:
username: xxx@xxx
password: 7aCTEJJM6eitNpJqmfsaPfERZmsQcawh
```

1. Optional: Prepare a list of import filename to ```import.txt```.
2. Run **main.exe**.

### Development

Expand Down
3 changes: 2 additions & 1 deletion conf.yml.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Please enter the credentials from Special:BotPasswords
# Do not share this file for privacy reasons.
# DO NOT share this file for security reasons.
# For more information, see https://github.com/AlanYe-Dev/mediawiki-file-import-utility#readme
bot:
username:
password:
16 changes: 12 additions & 4 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
MediaWiki Import File Utility
Author: _Wr_
Version: 0.3
Foundations:
- MediaWiki API Demos (MIT license)
Expand Down Expand Up @@ -42,21 +43,28 @@ def extract_filename(url_or_text):
return filename

# Startup message
print ("MediaWiki Import File Utility (by _Wr_)\nVersion: 0.2\n")
print ("MediaWiki Import File Utility (by _Wr_)\nVersion: 0.3\n")

# Read config file
#conf = yaml.load(open('./conf.yml'))
file_name = 'conf.yml'
eg_file_name = 'conf.yml.exmaple'

# Check if config file exists
if os.path.isfile(file_name):
print(f"[INFO] Detected config file '{file_name}'.")
with open('conf.yml', 'r') as config_file:
conf = yaml.safe_load(config_file)
else:
print(f"[ERROR] Did not detect config file '{file_name}'.\nPlease rename 'conf.yml.example' to 'conf.yml' and fill in the required fields.")
input ("Press Enter to exit...")
exit()
print(f"[WARNING] Did not detect config file '{file_name}'.\n[WARNING] Please rename 'conf.yml.example' to 'conf.yml' and fill in the required fields.\n[WARNING] For more information, see https://github.com/AlanYe-Dev/mediawiki-file-import-utility#readme")
if os.path.isfile(eg_file_name):
input ("Press Enter to exit...")
exit()
else:
with open("conf.yml.exmaple","w") as file:
file.write("# Please enter the credentials from Special:BotPasswords\n# DO NOT share this file for security reasons.\n# For more information, see https://github.com/AlanYe-Dev/mediawiki-file-import-utility#readme\nbot:\n username: \n password: ")
input ("Press Enter to exit...")
exit()



Expand Down

0 comments on commit dd62684

Please sign in to comment.