Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit 0a0effa

Browse files
committed
Update config, dev files, and docs
1 parent a3d94fc commit 0a0effa

File tree

3 files changed

+54
-17
lines changed

3 files changed

+54
-17
lines changed

README.md

+34-9
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,43 @@
22

33
This repo contains all of the challenges from [**r/dailyprogrammer**](http://reddit.com/r/dailyprogrammer) and also scripts used to pull challenges from the subreddit 3 times per week and to cleanup directories & remove unnecessary posts.
44

5-
## How to use
6-
The script can also be run via the command line by running `./post_challenges <number_of_challenges>`
5+
## Requirements
6+
7+
- Python 3
8+
- praw
9+
- pprint
710

8-
### Required Modules:
9-
- praw
10-
- subprocess
11-
- re
12-
- os
13-
- pprint
11+
## Installation
1412

15-
**post-challenges.py runs on Python 3.x**
13+
```bash
14+
$ pip3 install -r etc/requirements.txt
15+
```
16+
17+
## How to use
1618

19+
The script can also be run via the command line by running `./post-challenges.py <number_of_challenges>`
20+
It will look for a copy of `praw.ini`, an example is in `etc/praw.ini.example`
21+
22+
You may wish to run this in a temporary directory, to avoid adding folders directly to the top directory of the repo. Move the various levels of challenges into their respective end points.
23+
24+
### Example full run
25+
26+
```bash
27+
$ cd DailyProgrammerChallenges
28+
$ mkdir tmp
29+
$ cp etc/praw.ini.example tmp/praw.ini
30+
$ cd tmp
31+
# Edit praw.ini with the correct info
32+
$ ../post-challenges.py
33+
# Take a look at what was downloaded for any 'problems'
34+
$ mv *Easy* "Easy Challenges/."
35+
$ mv *Intermediate* "Intermediate Challenges/."
36+
$ mv *Hard* "Hard Challenges/."
37+
$ cd ..
38+
$ ./transform.py
39+
```
40+
41+
Examine the changes that `transform.py` performed and check that they seem okay.
1742

1843
## Challenges & Solutions
1944

etc/praw.ini.example

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[DEFAULT]
2+
client_id=CHANGE ME
3+
client_secret=CHANGE ME
4+
password=CHANGE ME
5+
username=CHANGE ME
6+
7+
# The URL prefix for OAuth-related requests.
8+
oauth_url=https://oauth.reddit.com
9+
10+
# The URL prefix for regular requests.
11+
reddit_url=https://www.reddit.com
12+

transform.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def update_challenge_dir_name(oldName, difficulty):
2020
suspects that it would fail a valid transformation.'''
2121

2222
# Find the challenge number:
23-
# tokens, delimited by ' '
24-
# find the first token that has one number embedded within
25-
# This should be the challenge number
26-
# This should avoid other strings with multiple numbers e.g. '[2016-05-20]'
23+
# tokens, delimited by ' '
24+
# find the first token that has one number embedded within
25+
# This should be the challenge number
26+
# This should avoid other strings with multiple numbers e.g. '[2016-05-20]'
2727
tokens = oldName.split()
2828

2929
currNum = ''
@@ -41,14 +41,14 @@ def update_challenge_dir_name(oldName, difficulty):
4141
n = n - 1
4242

4343
# No correct looking number found, or, it appears that the
44-
# number returned already appears to be in canonical form
44+
# number returned already appears to be in canonical form
4545
if (n == 0 or currNum[0] == '0'):
4646
return oldName
4747

4848
# Found a likely looking number
49-
# tokens now possess' the remaining title
50-
# a_token now has the original and possible multiple iteration number
51-
# such as 166b
49+
# tokens now possess' the remaining title
50+
# a_token now has the original and possible multiple iteration number
51+
# such as 166b
5252
i = re.findall(r'\S*' + re.escape(currNum) + '(\S*)$', a_token)
5353
newNum = ' ' + '0'*(4-n) + currNum + (i.pop() if (len(i) > 0) else ' ') + ' '
5454

0 commit comments

Comments
 (0)