Random words to replace the now broken loremipsum module, a few tidyups

pull/13/head
David Trail 11 years ago
parent 0fc430b8de
commit 27f39974b4

1
.gitignore vendored

@ -1,5 +1,6 @@
*.cfg
*.pyc
.idea/
bin/
include/
lib/

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.4.0 (/usr/bin/python3.4)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Shreddit.iml" filepath="$PROJECT_DIR$/.idea/Shreddit.iml" />
</modules>
</component>
</project>

@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -1,20 +1,34 @@
#!/usr/bin/env python3
#!/usr/bin/env python
import praw
from praw.errors import *
import os
import argparse
from re import sub
from random import shuffle, randint
from simpleconfigparser import simpleconfigparser
from praw.objects import Comment, Submission
from datetime import datetime, timedelta
from re import sub
from time import sleep
import praw
from praw.errors import InvalidUser, InvalidUserPass, RateLimitExceeded
from praw.objects import Comment, Submission
try:
from loremipsum import get_sentence
from loremipsum import get_sentence # This only works on Python 2
except ImportError:
def get_sentence():
return '''I have been Shreddited for privacy!\n\n\
https://github.com/x89/Shreddit/'''
if os.name == 'posix':
try:
# Try to generate a random string of words
fh = open('/usr/share/dict/words')
words = fh.read().splitlines()
fh.close()
shuffle(words)
def get_sentence():
return ' '.join(words[:randint(50, 150)])
except FileNotFoundError:
def get_sentence():
return '''I have been Shreddited for privacy!\n\n\
https://github.com/x89/Shreddit/'''
parser = argparse.ArgumentParser()
parser.add_argument(
@ -52,12 +66,12 @@ def login(user=None, password=None):
r.login(_user, _pass)
else:
r.login() # Let the user supply details
except InvalidUser as e:
raise InvalidUser("User does not exist.", e)
except InvalidUserPass as e:
raise InvalidUserPass(e)
except RateLimitExceeded:
raise RateLimitExceeded()
except NonExistentUser:
raise NonExistentUser("User does not exist")
raise InvalidUserPass("Specified an incorrect password.", e)
except RateLimitExceeded as e:
raise RateLimitExceeded("You're doing that too much.", e)
login(user=_user, password=_pass)
@ -128,4 +142,4 @@ for thing in things:
print('Editing and deleting {msg}'.format(msg=msg))
thing.edit(replacement_text)
if not edit_only:
thing.delete()
thing.delete()
Loading…
Cancel
Save