Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions asst1/asst1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
def swapchars(phrase):
import collections
onlyalpha= ''.join(c for c in phrase if c.isalpha())
onlyalpha=onlyalpha.lower()
m_common=collections.Counter(onlyalpha).most_common(1)
l_common=collections.Counter(onlyalpha).most_common()[:-2:-1]
new_phrase=""
for i in range(0, len(phrase)):
if phrase[i] is m_common[0][0]:
new_phrase += l_common[0][0]
elif phrase[i] == m_common[0][0].upper():
new_phrase += l_common[0][0].upper()
elif phrase[i] is l_common[0][0]:
new_phrase += m_common[0][0]
elif phrase[i] == l_common[0][0].upper():
new_phrase += m_common[0][0].upper()
else:
new_phrase += phrase[i]
return new_phrase

def sortcat(n, *args):
new_list=sorted(args, key=len, reverse=True)
outputstring=""
if n is -1:
for i in new_list:
outputstring+=new_list[i]
else:
for i in range(0, n):
outputstring+=new_list[i]
return outputstring

states_dict={}
with open("states.txt") as f:
for line in f:
(val, key) = line.split(",")
states_dict[key.strip("\n")] = val

def bluesclues(abbrev):
return states_dict[abbrev]

def bluesbooze(name):
for key, val in states_dict.items():
if val == name:
return key
21 changes: 21 additions & 0 deletions asst1/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def swapchars(phrase):
import collections
onlyalpha= ''.join(c for c in phrase if c.isalpha())
onlyalpha=onlyalpha.lower()
m_common=collections.Counter(onlyalpha).most_common(1)
l_common=collections.Counter(onlyalpha).most_common()[:-2:-1]
new_phrase=""
for i in range(0, len(phrase)):
if phrase[i] is m_common[0][0]:
new_phrase += l_common[0][0]
elif phrase[i] == m_common[0][0].upper():
new_phrase += l_common[0][0].upper()
elif phrase[i] is l_common[0][0]:
new_phrase += m_common[0][0]
elif phrase[i] == l_common[0][0].upper():
new_phrase += m_common[0][0].upper()
else:
new_phrase += phrase[i]
return new_phrase

print swapchars("I\'m just a chi-town coder with a nice flow.")
Empty file added asst2/asst2.py
Empty file.
53 changes: 51 additions & 2 deletions asst2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ def __init__(self, year, month, day, contributors):

# TODO: Delete the following line and replace it with a line
# that stores the year, month, and day (hint: check out datetime.date)
self.creation_date = None
self.year = year
self.month = month
self.day = day

#year = datetime.date.self.strftime("%Y")
#month = datetime.date.self.strftime("%B")
#day = datetime.date.self.strftime("%d")

# list of contirbutors
self.contributors = contributors
Expand All @@ -21,8 +27,51 @@ def __init__(self, year, month, day, contributors):
def show(self):
raise NotImplementedError


# TODO: Define an Article class that extends the Content class
class Article(Content):
def __init__(self, year, month, day, contributors, headline, content, show):
super(Article, self).__init__(year, month, day, contributors)
self.headline = headline
self.content = content

def show(self):
print "headline: " + headline + "\ncontributors: "
a = 0
while a != (len(contributors) - 1):
print contributors[a] + " , "
print contributor[len(contributor)-1] + "\ndate: "
if month > 9:
print month + "/"
else:
print "0" + month + "/"
if day > 9:
print day
else:
print "0" + day
print "/" + "year\n\n" + content

# TODO: Define a Picture class that extends the Content class
class Picture(Content):
def __init__(self, year, month, day, contributors, title, caption, path, show):
super(Picture, self).__init__(year, month, day, contributors)
self.caption = caption
self.path = path

def show(self):
print "headline: " + headline + "\ncontributors: "
a = 0
while a != (len(contributors)-1):
print contributors[a] + " , "
print contributor[leng(contributor)-1] + "\ndate: "
if month > 9:
print month + "/"
else:
print "0" + month + "/"
if day > 9:
print day
else:
print "0" + day
print "/" + "year\n\n"
from PIL import Image
Image.open(path).show
print caption
Binary file added asst3/.DS_Store
Binary file not shown.
Empty file.
Binary file added asst3/newspaper/content/__init__.pyc
Binary file not shown.
6 changes: 6 additions & 0 deletions asst3/newspaper/content/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.contrib import admin

# Register your models here.
Binary file added asst3/newspaper/content/admin.pyc
Binary file not shown.
8 changes: 8 additions & 0 deletions asst3/newspaper/content/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.apps import AppConfig


class ContentConfig(AppConfig):
name = 'content'
47 changes: 47 additions & 0 deletions asst3/newspaper/content/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-10-22 01:31
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Content',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=500)),
('subtitle', models.CharField(max_length=500)),
('pub_date', models.DateTimeField(verbose_name='date published')),
],
),
migrations.CreateModel(
name='Contributor',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=500)),
('last_name', models.CharField(max_length=500)),
],
),
migrations.CreateModel(
name='Article',
fields=[
('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='content.Content')),
('text', models.TextField()),
],
bases=('content.content',),
),
migrations.AddField(
model_name='content',
name='contributors',
field=models.ManyToManyField(related_name='content', to='content.Contributor'),
),
]
Binary file not shown.
Empty file.
Binary file added asst3/newspaper/content/migrations/__init__.pyc
Binary file not shown.
25 changes: 25 additions & 0 deletions asst3/newspaper/content/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models

# Create your models here.

class Content(models.Model):
title = models.CharField(max_length=500)
subtitle = models.CharField(max_length=500)
contributors = models.ManyToManyField('Contributor',
related_name='content')
pub_date = models.DateTimeField('date published')


class Article(Content):
text = models.TextField()


class Contributor(models.Model):
first_name = models.CharField(max_length=500)
last_name = models.CharField(max_length=500)

def __die__(self):
self.delete(using=DEFAULT_DB_ALIAS, keep_parents=False)
Binary file added asst3/newspaper/content/models.pyc
Binary file not shown.
6 changes: 6 additions & 0 deletions asst3/newspaper/content/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.test import TestCase

# Create your tests here.
6 changes: 6 additions & 0 deletions asst3/newspaper/content/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.shortcuts import render

# Create your views here.
Binary file added asst3/newspaper/db.sqlite3
Binary file not shown.
22 changes: 22 additions & 0 deletions asst3/newspaper/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "newspaper.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)
Empty file.
Binary file added asst3/newspaper/newspaper/__init__.pyc
Binary file not shown.
121 changes: 121 additions & 0 deletions asst3/newspaper/newspaper/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
"""
Django settings for newspaper project.

Generated by 'django-admin startproject' using Django 1.11.6.

For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'm2(3a(&2=kv@#361(ai(k_d)&uwu=i-cfdd+rlv@r(mtl@iy79'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'content',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'newspaper.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'newspaper.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/

STATIC_URL = '/static/'
Binary file added asst3/newspaper/newspaper/settings.pyc
Binary file not shown.
Loading