Skip to content

Commit

Permalink
Restructured project, added basic setup.py file
Browse files Browse the repository at this point in the history
Module files themselves are in a new doll folder, setup.py has been
added to the root directory.
  • Loading branch information
Matthew Badger authored and Matthew Badger committed Aug 30, 2015
1 parent f93763f commit 536d32c
Show file tree
Hide file tree
Showing 15 changed files with 367 additions and 55 deletions.
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
222 changes: 222 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
#################
## Eclipse
#################

*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath


#################
## Visual Studio
#################

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml
*.publishproj

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

#############
## Windows detritus
#############

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac crap
.DS_Store


#############
## Python
#############

*.py[cod]

# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox

#Translations
*.mo

#Mr Developer
.mr.developer.cfg

# PyCharm
.idea/
__pycache__
*.pyc
*.pyo
17 changes: 0 additions & 17 deletions db_input_parser/__init__.py

This file was deleted.

1 change: 1 addition & 0 deletions doll/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__author__ = 'Matthew'
40 changes: 40 additions & 0 deletions doll/db_input_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
__author__ = 'Matthew'

import os

from db_input_parser.add_database_types import create_type_contents
from db_input_parser.parse_dictionary import parse_dict_file
from doll.db_input_parser.parse_inflections import parse_inflect_file


def parse_all_inputs(words_folder, commit_changes):
"""Creates the database and parses all the inputs"""

# Add a trailing slash if necessary
if (words_folder[-1:] != '/'):
words_folder += '/'

# First check that our words folder exists
if not os.path.isdir(words_folder):
print('Cannot find words_folder at {0}! Exiting...'.format(words_folder))
return

# And then that our input files exist
files_to_find = ['INFLECTS.LAT', 'DICTLINE.GEN']
error_string = ', '.join([f for f in files_to_find if not os.path.isfile(words_folder + f)])

if not error_string == '':
print('Unable to find the following file(s): ' + error_string + '. Exiting...')
return

'''if os.path.isfile(config['db_file']):
if not input('Database file exists, overwrite? ([Y]es/ No)')[:1] == 'Y':
print('Database file exists, exiting...')
return'''

create_type_contents()

parse_inflect_file(inflect_file=words_folder + 'INFLECTS.LAT', commit_changes=commit_changes)

parse_dict_file(dict_file=words_folder + 'DICTLINE.GEN', commit_changes=commit_changes)

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

__author__ = 'Matthew Badger'

from doll_db.model import *
from doll.doll_db import *


# Add the basic database types
Expand Down Expand Up @@ -186,4 +186,6 @@ def create_type_contents():
Connection.session.add(Mood(code='INF', name='Infinitive', description=''))
Connection.session.add(Mood(code='PPL', name='Participle', description=''))

Connection.session.add(Language(code='E', name='English', description='English translations from Words'))

Connection.session.commit()
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__author__ = 'Matthew Badger'

from doll_db.model import *
from doll.doll_db import *

def parse_dict_file(dict_file, commit_changes=False):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__author__ = 'Matthew Badger'

from doll_db.model import *
from doll.doll_db import *

"""Parses the inflections input file.
Expand Down
27 changes: 27 additions & 0 deletions doll/doll_db/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
__author__ = 'Matthew Badger'

from sqlalchemy import engine_from_config
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base

from doll.doll_db.config import config

Base = declarative_base()


'''Connection class
Connects to the database in the root folder of the application
'''

# Connects to the database
class Connection:
__engine = engine_from_config(config, echo=False)

Base.metadata.create_all(__engine)

__Session = sessionmaker()
__Session.configure(bind=__engine)

session = __Session()
6 changes: 6 additions & 0 deletions doll/doll_db/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
config = {
'db_file': 'doll_db/doll.db',
'sqlalchemy.url': 'sqlite:///doll_db/doll.db',
'sqlalchemy.pool_recycle': '50',
'sqlalchemy.echo': 'false'
}
Loading

0 comments on commit 536d32c

Please sign in to comment.