Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Ethan Mertz
/
CS-123-Final
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a1e212d0
authored
Jun 03, 2018
by
Anselm Jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comment spacing
parent
369c6124
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
49 deletions
Python/collectvariables.py
Python/pyfilesplit.py
Python/pyfuncsplit.py
text_to_dict.py
util.py
Python/collectvariables.py
View file @
a1e212d0
...
...
@@ -6,14 +6,14 @@ import glob
var
=
"[
\
s]*([a-zA-Z_][
\
w, ]*)[
\
s]*=[^=]"
def
get_unique_vars
(
filename
):
'''
Goes through a file and finds all of the unique variable names.
Input:
filename(string): name of file from which to pull variable names.
Output:
unique_vs(set): set containing variable names as strings
'''
'''
Goes through a file and finds all of the unique variable names.
Input:
filename(string): name of file from which to pull variable names.
Output:
unique_vs(set): set containing variable names as strings
'''
#Create set to accumulate variables.
unique_vs
=
set
()
with
open
(
filename
)
as
f
:
...
...
@@ -28,15 +28,15 @@ Output:
def
main
():
'''
Works over our pydata directory and pulls variables from the number of files
specified.
Input:
subset(int): number of files to run over within the directory.
Output:
None, but writes all variable files to our pyvariables directory.
'''
'''
Works over our pydata directory and pulls variables from the number of files
specified.
Input:
subset(int): number of files to run over within the directory.
Output:
None, but writes all variable files to our pyvariables directory.
'''
count
=
0
for
filename
in
glob
.
glob
(
"pydata/pyfile*.txt"
):
if
count
==
subset
:
...
...
Python/pyfilesplit.py
View file @
a1e212d0
import
re
def
go
(
subset
):
'''
Takes in the raw python text file and splits the file into a subset.
'''
Takes in the raw python text file and splits the file into a subset.
Input:
subset(int): number of files desired for subset.
Output:
None but the function files will be written to the directory pyfiles.
'''
Input:
subset(int): number of files desired for subset.
Output:
None but the function files will be written to the directory pyfiles.
'''
#Initialize counters and boolean.
count
=
0
prev
=
False
...
...
Python/pyfuncsplit.py
View file @
a1e212d0
import
re
def
go
(
subset
):
'''
Takes in the raw python text file and splits the functions into a subset of
individual files.
'''
Takes in the raw python text file and splits the functions into a subset of
individual files.
Input:
subset(int): number of files desired for subset.
Output:
None but the function files will be written to the directory pyfunctions
with the names, parameters, and body separated.
'''
Input:
subset(int): number of files desired for subset.
Output:
None but the function files will be written to the directory pyfunctions
with the names, parameters, and body separated.
'''
with
open
(
"data/python.txt"
,
'r'
)
as
f
:
#Initializes all counters and function accumulator.
func
=
False
...
...
text_to_dict.py
View file @
a1e212d0
import
json
def
to_json
(
filename
,
dataname
):
'''
Takes the output of mrjob and turns it into a json.
'''
Takes the output of mrjob and turns it into a json.
Inputs:
filename(string): name of .txt file to be processed.
dataname(string): name of .json file to be written.
Outputs:
.json file with the output.
'''
Inputs:
filename(string): name of .txt file to be processed.
dataname(string): name of .json file to be written.
Outputs:
.json file with the output.
'''
resultdict
=
{}
with
open
(
filename
)
as
resultfile
:
results
=
resultfile
.
readlines
()
...
...
util.py
View file @
a1e212d0
...
...
@@ -6,15 +6,15 @@ REG_F = "def [a-zA-Z_][\w]*\("
DEFAULT_RETURN
=
1
def
funcsim
(
file1name
,
file2name
):
'''
Given two function files generated by pyfuncsplit.py, we get
the parameters of these functions.
'''
Given two function files generated by pyfuncsplit.py, we get
the parameters of these functions.
Inputs:
file1name, file2name (strings): files to be read.
Output:
tuple with name, parameters, and text of files.
'''
Inputs:
file1name, file2name (strings): files to be read.
Output:
tuple with name, parameters, and text of files.
'''
with
open
(
file1name
)
as
f1
:
with
open
(
file2name
)
as
f2
:
f1text
=
f1
.
read
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment