-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfun.py
35 lines (29 loc) · 773 Bytes
/
fun.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import hashlib
import pymysql
import os, os.path
from pathlib import Path
import string
rootFolder = 'sastaGoogle/static/simple/articles'
# Prepare Punctuation Striper
translator = str.maketrans('', '', string.punctuation)
# Establishes the connection to database
def dbSetup():
conn = pymysql.connect(
host='127.0.0.1',
port=3306,
user='root',
passwd='pword',
db='sastaGoogle')
cur = conn.cursor()
return conn, cur
# Closes the connection
def dbClose(conn, cur):
cur.close()
conn.close()
## Hashing up the filename for storing: 32-bit Unique
def hashF (val):
return hashlib.md5(val.encode()).hexdigest()
def getFiles(rF = rootFolder):
arrayofpath = Path (rF).glob("**/*")
files = [x for x in arrayofpath if x.is_file()]
return files