Skip to content

Commit

Permalink
#50 Use autoformatter for python
Browse files Browse the repository at this point in the history
  • Loading branch information
ilesoft authored Oct 23, 2024
2 parents 4f6afd6 + 789daf0 commit a29094e
Show file tree
Hide file tree
Showing 30 changed files with 5,378 additions and 4,000 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ f1a94d22a334661a8ddbd7a04d5c1d480886ef32

# Use spaces instead of tabs in template files
ae6391ac34b6f959fd16053f24076353aae0e54b

# Format python code with black
b215abbc7ae11614bab50fb7c3b95c307cf933d5
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 mukaista 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")
Loading

0 comments on commit a29094e

Please sign in to comment.