Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use print function from __future__ #51

Closed
wants to merge 4 commits into from
Closed
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
17 changes: 17 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ name: Automated tests
on: pull_request

jobs:
auto-formatting:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12.1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install 'black[python2]==21.12b0'
pip install click==8.0.2 # newer version is incompatible
- name: Check formatting
run: |
black -t py27 --check web/
black -t py27 --check web/**/*.py.example
unit-tests-sqlite:
runs-on: ubuntu-latest
timeout-minutes: 15
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ Tämän ohjelman mukana pitäisi tulla kopio GPL-lisenssistä; jos näin ei ole,
Hakemistosta `./web/roobt` löytyy myös toinen robot-tiedosto nimeltään
`autentikointi.txt`, mutta sen ajaminen ei taida onnistua, ellei ensin toteuta
Kipaan suunniteltua kirjautumista.

### Python-koodin formatointi

Koodi noudattaa Black-autoformatterin vesion 21.12.b0 mukausta tyyliä. Formatointi tarkastetaan osana CI-putkea.
14 changes: 6 additions & 8 deletions web/legacy/RenameFixture.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

if __name__ == "__main__":
source=open( "fixtures/old.xml" , "r" )
koodi=source.read()
source.close()
koodi=koodi.replace("legacy","tupa")
source=open( "fixtures/old.xml","w" )
source.write(koodi)

source = open("fixtures/old.xml", "r")
koodi = source.read()
source.close()
koodi = koodi.replace("legacy", "tupa")
source = open("fixtures/old.xml", "w")
source.write(koodi)
297 changes: 153 additions & 144 deletions web/legacy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,155 +7,164 @@

from django.db import models

class Kisa(models.Model) :
#gen_legacy_class Kisa
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
aika = models.CharField(max_length=255, blank=True)
paikka = models.CharField(max_length=255)
class Meta:
db_table = u'tupa_kisa'


#end_legacy_class

class Sarja(models.Model) :
#gen_legacy_class Sarja
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
vartion_maksimikoko = models.IntegerField(null=True, blank=True)
vartion_minimikoko = models.IntegerField(null=True, blank=True)
kisa = models.ForeignKey(Kisa)
class Meta:
db_table = u'tupa_sarja'


#end_legacy_class

class Vartio(models.Model) :
#gen_legacy_class Vartio
id = models.IntegerField(primary_key=True)
nro = models.IntegerField()
nimi = models.CharField(max_length=255)
sarja = models.ForeignKey(Sarja)
piiri = models.CharField(max_length=255)
lippukunta = models.CharField(max_length=255)
puhelinnro = models.CharField(max_length=255)
sahkoposti = models.CharField(max_length=255)
osoite = models.CharField(max_length=255)
keskeyttanyt = models.IntegerField(null=True, blank=True)
ulkopuolella = models.IntegerField(null=True, blank=True)
class Meta:
db_table = u'tupa_vartio'


#end_legacy_class

class Henkilo(models.Model) :
#gen_legacy_class Henkilo
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
syntymavuosi = models.IntegerField(null=True, blank=True)
lippukunta = models.CharField(max_length=255, blank=True)
jasennumero = models.CharField(max_length=15, blank=True)
puhelin_nro = models.CharField(max_length=15, blank=True)
homma = models.CharField(max_length=255, blank=True)
class Meta:
db_table = u'tupa_henkilo'


#end_legacy_class

class Tehtava(models.Model) :
#gen_legacy_class Tehtava
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
tehtavaryhma = models.CharField(max_length=255)
tehtavaluokka = models.CharField(max_length=255)
rastikasky = models.TextField()
jarjestysnro = models.IntegerField()
kaava = models.CharField(max_length=255)
sarja = models.ForeignKey(Sarja)
tarkistettu = models.BooleanField()
class Meta:
db_table = u'tupa_tehtava'


#end_legacy_class


class Osatehtava(models.Model) :
#gen_legacy_class Osatehtava
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
tyyppi = models.CharField(max_length=255)
kaava = models.CharField(max_length=255)
tehtava = models.ForeignKey(Tehtava)
class Meta:
db_table = u'tupa_osatehtava'


#end_legacy_class

class Syotemaarite(models.Model) :
#gen_legacy_class Syotemaarite
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
tyyppi = models.CharField(max_length=255)
kali_vihje = models.CharField(max_length=255, blank=True)
osa_tehtava = models.ForeignKey(Osatehtava)
class Meta:
db_table = u'tupa_syotemaarite'


#end_legacy_class

class Syote(models.Model) :
#gen_legacy_class Syote
id = models.IntegerField(primary_key=True)
arvo = models.CharField(max_length=255, blank=True)
vartio = models.ForeignKey(Vartio, null=True, blank=True)
maarite = models.ForeignKey(Syotemaarite)
tarkistus = models.CharField(max_length=255, blank=True)
class Meta:
db_table = u'tupa_syote'


#end_legacy_class

class Tuomarineuvostulos(models.Model) :
#gen_legacy_class Tuomarineuvostulos
id = models.IntegerField(primary_key=True)
vartio = models.ForeignKey(Vartio)
tehtava = models.ForeignKey(Tehtava)
pisteet = models.CharField(max_length=255)
class Meta:
db_table = u'tupa_tuomarineuvostulos'


#end_legacy_class

class Kisa(models.Model):
# gen_legacy_class Kisa
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
aika = models.CharField(max_length=255, blank=True)
paikka = models.CharField(max_length=255)

class Meta:
db_table = u"tupa_kisa"

# end_legacy_class


class Sarja(models.Model):
# gen_legacy_class Sarja
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
vartion_maksimikoko = models.IntegerField(null=True, blank=True)
vartion_minimikoko = models.IntegerField(null=True, blank=True)
kisa = models.ForeignKey(Kisa)

class Meta:
db_table = u"tupa_sarja"

# end_legacy_class


class Vartio(models.Model):
# gen_legacy_class Vartio
id = models.IntegerField(primary_key=True)
nro = models.IntegerField()
nimi = models.CharField(max_length=255)
sarja = models.ForeignKey(Sarja)
piiri = models.CharField(max_length=255)
lippukunta = models.CharField(max_length=255)
puhelinnro = models.CharField(max_length=255)
sahkoposti = models.CharField(max_length=255)
osoite = models.CharField(max_length=255)
keskeyttanyt = models.IntegerField(null=True, blank=True)
ulkopuolella = models.IntegerField(null=True, blank=True)

class Meta:
db_table = u"tupa_vartio"

# end_legacy_class


class Henkilo(models.Model):
# gen_legacy_class Henkilo
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
syntymavuosi = models.IntegerField(null=True, blank=True)
lippukunta = models.CharField(max_length=255, blank=True)
jasennumero = models.CharField(max_length=15, blank=True)
puhelin_nro = models.CharField(max_length=15, blank=True)
homma = models.CharField(max_length=255, blank=True)

class Meta:
db_table = u"tupa_henkilo"

# end_legacy_class


class Tehtava(models.Model):
# gen_legacy_class Tehtava
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
tehtavaryhma = models.CharField(max_length=255)
tehtavaluokka = models.CharField(max_length=255)
rastikasky = models.TextField()
jarjestysnro = models.IntegerField()
kaava = models.CharField(max_length=255)
sarja = models.ForeignKey(Sarja)
tarkistettu = models.BooleanField()

class Meta:
db_table = u"tupa_tehtava"

# end_legacy_class


class Osatehtava(models.Model):
# gen_legacy_class Osatehtava
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
tyyppi = models.CharField(max_length=255)
kaava = models.CharField(max_length=255)
tehtava = models.ForeignKey(Tehtava)

class Meta:
db_table = u"tupa_osatehtava"

# end_legacy_class


class Syotemaarite(models.Model):
# gen_legacy_class Syotemaarite
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
tyyppi = models.CharField(max_length=255)
kali_vihje = models.CharField(max_length=255, blank=True)
osa_tehtava = models.ForeignKey(Osatehtava)

class Meta:
db_table = u"tupa_syotemaarite"

# end_legacy_class


class Syote(models.Model):
# gen_legacy_class Syote
id = models.IntegerField(primary_key=True)
arvo = models.CharField(max_length=255, blank=True)
vartio = models.ForeignKey(Vartio, null=True, blank=True)
maarite = models.ForeignKey(Syotemaarite)
tarkistus = models.CharField(max_length=255, blank=True)

class Meta:
db_table = u"tupa_syote"

# end_legacy_class


class Tuomarineuvostulos(models.Model):
# gen_legacy_class Tuomarineuvostulos
id = models.IntegerField(primary_key=True)
vartio = models.ForeignKey(Vartio)
tehtava = models.ForeignKey(Tehtava)
pisteet = models.CharField(max_length=255)

class Meta:
db_table = u"tupa_tuomarineuvostulos"

# end_legacy_class


class Testaustulos(models.Model):
#gen_legacy_class Testaustulos
id = models.IntegerField(primary_key=True)
vartio = models.ForeignKey(Vartio)
tehtava = models.ForeignKey(Tehtava)
pisteet = models.CharField(max_length=255)
class Meta:
db_table = u'tupa_testaustulos'
# gen_legacy_class Testaustulos
id = models.IntegerField(primary_key=True)
vartio = models.ForeignKey(Vartio)
tehtava = models.ForeignKey(Tehtava)
pisteet = models.CharField(max_length=255)

class Meta:
db_table = u"tupa_testaustulos"

#end_legacy_class
# end_legacy_class

class Parametri(models.Model) :
#gen_legacy_class Parametri
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
arvo = models.CharField(max_length=255)
osa_tehtava = models.ForeignKey(Osatehtava)
class Meta:
db_table = u'tupa_parametri'

class Parametri(models.Model):
# gen_legacy_class Parametri
id = models.IntegerField(primary_key=True)
nimi = models.CharField(max_length=255)
arvo = models.CharField(max_length=255)
osa_tehtava = models.ForeignKey(Osatehtava)

#end_legacy_class
class Meta:
db_table = u"tupa_parametri"

# end_legacy_class
2 changes: 1 addition & 1 deletion web/legacySettings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from settings import *
INSTALLED_APPS.append( 'legacy')

INSTALLED_APPS.append("legacy")
23 changes: 14 additions & 9 deletions web/manage.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
#!/usr/bin/python2

from __future__ import print_function
import sys
print sys.path

print(sys.path)
from django.core.management import execute_manager

try:
import settings #
import legacySettings # Legacy settings for exporting an legacy db
import settings #
import legacySettings # Legacy settings for exporting an legacy db
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)

sys.stderr.write(
"Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n"
% __file__
)
sys.exit(1)

if __name__ == "__main__":
set=settings
if len(sys.argv) :
if sys.argv[1] == 'dumpdata':
set=legacySettings
set = settings
if len(sys.argv):
if sys.argv[1] == "dumpdata":
set = legacySettings
execute_manager(set)

Loading