Skip to content

Commit

Permalink
Import stuff inside src by fullpath
Browse files Browse the repository at this point in the history
and get rid of sys.path.insert shenanigans
  • Loading branch information
Gatsik committed Sep 14, 2024
1 parent 0b69a2b commit 21f23b6
Show file tree
Hide file tree
Showing 225 changed files with 892 additions and 869 deletions.
4 changes: 2 additions & 2 deletions res/chat/channel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@
<customwidget>
<class>ChatLineEdit</class>
<extends>QLineEdit</extends>
<header location="global">chat.chatlineedit</header>
<header location="global">src.chat.chatlineedit</header>
</customwidget>
<customwidget>
<class>ChatterListView</class>
<extends>QListView</extends>
<header location="global">chat.chatterlistview</header>
<header location="global">src.chat.chatterlistview</header>
</customwidget>
</customwidgets>
<tabstops>
Expand Down
2 changes: 1 addition & 1 deletion res/coop/coop.ui
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ p, li { white-space: pre-wrap; }
<customwidget>
<class>CoopLeaderboardTableView</class>
<extends>QTableView</extends>
<header>coop.cooptableview</header>
<header>src.coop.cooptableview</header>
</customwidget>
</customwidgets>
<resources/>
Expand Down
4 changes: 2 additions & 2 deletions res/stats/leaderboard.ui
Original file line number Diff line number Diff line change
Expand Up @@ -779,12 +779,12 @@
<customwidget>
<class>LeaderboardTableView</class>
<extends>QTableView</extends>
<header location="global">stats.itemviews.leaderboardtableview</header>
<header location="global">src.stats.itemviews.leaderboardtableview</header>
</customwidget>
<customwidget>
<class>LeaderboardLineEdit</class>
<extends>QLineEdit</extends>
<header location="global">stats.leaderboardlineedit</header>
<header location="global">src.stats.leaderboardlineedit</header>
</customwidget>
</customwidgets>
<resources/>
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
else:
from distutils.core import setup

sys.path.insert(0, "src")

company_name = "FAF Community"
product_name = "Forged Alliance Forever"

if sys.platform == "win32":
import config.version as version
from src.config import version

root_dir = os.path.dirname(os.path.abspath(__file__))
res_dir = os.path.join(root_dir, "res")
Expand Down
16 changes: 7 additions & 9 deletions src/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
from PyQt6.QtWidgets import QMessageBox
from PyQt6.QtWidgets import QStyleFactory

import util
import util.crash
from config import Settings
from src import util
from src.config import Settings
from src.util import crash

# Some linux distros (like Gentoo) make package scripts available
# by copying and modifying them. This breaks path to our modules.
Expand Down Expand Up @@ -70,7 +70,7 @@ def excepthook(
),
)
logger.error("Runtime Info:\n{}".format(util.crash.runtime_info()))
dialog = util.crash.CrashDialog((exc_type, exc_value, traceback_object))
dialog = crash.CrashDialog((exc_type, exc_value, traceback_object))
answer = dialog.exec()

if answer == QDialog.DialogCode.Rejected:
Expand Down Expand Up @@ -100,7 +100,7 @@ def run_faf():
util.THEME.loadTheme()

# Create client singleton and connect
import client
from src import client

faf_client = client.instance
faf_client.setup()
Expand All @@ -121,7 +121,7 @@ def set_style(app: QApplication) -> None:
if __name__ == '__main__':
import logging

import config
from src import config

QApplication.setAttribute(Qt.ApplicationAttribute.AA_ShareOpenGLContexts)
app = QApplication(["FAF Python Client"] + trailing_args)
Expand Down Expand Up @@ -155,16 +155,14 @@ def set_style(app: QApplication) -> None:
sys.excepthook = excepthook

if len(trailing_args) == 0:
# Do the magic
sys.path.extend(['.'])
run_faf()
else:
# Try to interpret the argument as a replay.
if (
trailing_args[0].lower().endswith(".fafreplay")
or trailing_args[0].lower().endswith(".scfareplay")
):
import fa
from src import fa
fa.replay(trailing_args[0], True) # Launch as detached process

# End of show
Expand Down
2 changes: 1 addition & 1 deletion src/api/ApiAccessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from PyQt6.QtCore import pyqtSignal

from api.ApiBase import ApiBase
from src.api.ApiBase import ApiBase

logger = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions src/api/ApiBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from PyQt6.QtNetwork import QNetworkReply
from PyQt6.QtNetwork import QNetworkRequest

from config import Settings
from oauth.oauth_flow import OAuth2Flow
from oauth.oauth_flow import OAuth2FlowInstance
from src.config import Settings
from src.oauth.oauth_flow import OAuth2Flow
from src.oauth.oauth_flow import OAuth2FlowInstance

logger = logging.getLogger(__name__)

Expand Down
10 changes: 5 additions & 5 deletions src/api/coop_api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from api.ApiAccessors import DataApiAccessor
from api.models.CoopResult import CoopResult
from api.models.CoopScenario import CoopScenario
from api.parsers.CoopResultParser import CoopResultParser
from api.parsers.CoopScenarioParser import CoopScenarioParser
from src.api.ApiAccessors import DataApiAccessor
from src.api.models.CoopResult import CoopResult
from src.api.models.CoopScenario import CoopScenario
from src.api.parsers.CoopResultParser import CoopResultParser
from src.api.parsers.CoopScenarioParser import CoopScenarioParser


class CoopApiAccessor(DataApiAccessor):
Expand Down
10 changes: 5 additions & 5 deletions src/api/featured_mod_api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging

from api.ApiAccessors import DataApiAccessor
from api.models.FeaturedMod import FeaturedMod
from api.models.FeaturedModFile import FeaturedModFile
from api.parsers.FeaturedModFileParser import FeaturedModFileParser
from api.parsers.FeaturedModParser import FeaturedModParser
from src.api.ApiAccessors import DataApiAccessor
from src.api.models.FeaturedMod import FeaturedMod
from src.api.models.FeaturedModFile import FeaturedModFile
from src.api.parsers.FeaturedModFileParser import FeaturedModFileParser
from src.api.parsers.FeaturedModParser import FeaturedModParser

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/api/matchmaker_queue_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from api.ApiAccessors import DataApiAccessor
from src.api.ApiAccessors import DataApiAccessor

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/api/models/AbstractEntity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import Field

from api.models.ConfiguredModel import ConfiguredModel
from src.api.models.ConfiguredModel import ConfiguredModel


class AbstractEntity(ConfiguredModel):
Expand Down
5 changes: 3 additions & 2 deletions src/api/models/Achievement.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

from api.models.AbstractEntity import AbstractEntity
from pydantic import Field
from util import StringValuedEnum

from src.api.models.AbstractEntity import AbstractEntity
from src.util import StringValuedEnum


class State(StringValuedEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/api/models/Avatar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from api.models.AbstractEntity import AbstractEntity
from src.api.models.AbstractEntity import AbstractEntity


class Avatar(AbstractEntity):
Expand Down
5 changes: 3 additions & 2 deletions src/api/models/AvatarAssignment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from api.models.AbstractEntity import AbstractEntity
from api.models.Avatar import Avatar
from pydantic import Field

from src.api.models.AbstractEntity import AbstractEntity
from src.api.models.Avatar import Avatar


class AvatarAssignment(AbstractEntity):
expires_at: str | None = Field(alias="expiresAt")
Expand Down
2 changes: 1 addition & 1 deletion src/api/models/CoopMission.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import Field

from api.models.ConfiguredModel import ConfiguredModel
from src.api.models.ConfiguredModel import ConfiguredModel


class CoopMission(ConfiguredModel):
Expand Down
4 changes: 2 additions & 2 deletions src/api/models/CoopResult.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pydantic import Field

from api.models.ConfiguredModel import ConfiguredModel
from api.models.Game import Game
from src.api.models.ConfiguredModel import ConfiguredModel
from src.api.models.Game import Game


class CoopResult(ConfiguredModel):
Expand Down
4 changes: 2 additions & 2 deletions src/api/models/CoopScenario.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pydantic import Field

from api.models.ConfiguredModel import ConfiguredModel
from api.models.CoopMission import CoopMission
from src.api.models.ConfiguredModel import ConfiguredModel
from src.api.models.CoopMission import CoopMission


class CoopScenario(ConfiguredModel):
Expand Down
3 changes: 2 additions & 1 deletion src/api/models/Event.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from api.models.ConfiguredModel import ConfiguredModel
from pydantic import Field

from src.api.models.ConfiguredModel import ConfiguredModel


class Event(ConfiguredModel):
xd: str = Field(alias="id")
Expand Down
2 changes: 1 addition & 1 deletion src/api/models/FeaturedMod.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import Field

from api.models.ConfiguredModel import ConfiguredModel
from src.api.models.ConfiguredModel import ConfiguredModel


class FeaturedMod(ConfiguredModel):
Expand Down
2 changes: 1 addition & 1 deletion src/api/models/FeaturedModFile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import Field

from api.models.ConfiguredModel import ConfiguredModel
from src.api.models.ConfiguredModel import ConfiguredModel


class FeaturedModFile(ConfiguredModel):
Expand Down
6 changes: 3 additions & 3 deletions src/api/models/Game.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from pydantic import Field

from api.models.ConfiguredModel import ConfiguredModel
from api.models.Player import Player
from api.models.PlayerStats import PlayerStats
from src.api.models.ConfiguredModel import ConfiguredModel
from src.api.models.Player import Player
from src.api.models.PlayerStats import PlayerStats


class Game(ConfiguredModel):
Expand Down
3 changes: 2 additions & 1 deletion src/api/models/GamePlayerStats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from api.models.ConfiguredModel import ConfiguredModel
from pydantic import Field

from src.api.models.ConfiguredModel import ConfiguredModel


class GamePlayerStats(ConfiguredModel):
xd: str = Field(alias="id")
Expand Down
8 changes: 4 additions & 4 deletions src/api/models/GeneratedMapParams.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from pydantic import Field

from api.models.ConfiguredModel import ConfiguredModel
from api.models.Map import Map
from api.models.MapType import MapType
from api.models.MapVersion import MapVersion
from src.api.models.ConfiguredModel import ConfiguredModel
from src.api.models.Map import Map
from src.api.models.MapType import MapType
from src.api.models.MapVersion import MapVersion


class GeneratedMapParams(ConfiguredModel):
Expand Down
3 changes: 2 additions & 1 deletion src/api/models/Leaderboard.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

from api.models.AbstractEntity import AbstractEntity
from pydantic import Field

from src.api.models.AbstractEntity import AbstractEntity


class Leaderboard(AbstractEntity):
description: str = Field(alias="descriptionKey")
Expand Down
5 changes: 3 additions & 2 deletions src/api/models/LeaderboardRating.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from api.models.AbstractEntity import AbstractEntity
from api.models.Leaderboard import Leaderboard
from pydantic import Field

from src.api.models.AbstractEntity import AbstractEntity
from src.api.models.Leaderboard import Leaderboard


class LeaderboardRating(AbstractEntity):
deviation: float
Expand Down
7 changes: 4 additions & 3 deletions src/api/models/LeaderboardRatingJournal.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from api.models.ConfiguredModel import ConfiguredModel
from api.models.GamePlayerStats import GamePlayerStats
from api.models.Leaderboard import Leaderboard
from pydantic import Field

from src.api.models.ConfiguredModel import ConfiguredModel
from src.api.models.GamePlayerStats import GamePlayerStats
from src.api.models.Leaderboard import Leaderboard


class LeaderboardRatingJournal(ConfiguredModel):
create_time: str = Field(alias="createTime")
Expand Down
5 changes: 3 additions & 2 deletions src/api/models/LeagueDivision.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from api.models.ConfiguredModel import ConfiguredModel
from api.models.LeagueSeason import LeagueSeason
from pydantic import Field

from src.api.models.ConfiguredModel import ConfiguredModel
from src.api.models.LeagueSeason import LeagueSeason


class LeagueDivision(ConfiguredModel):
xd: str = Field(alias="id")
Expand Down
3 changes: 2 additions & 1 deletion src/api/models/LeagueLeaderboard.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from api.models.ConfiguredModel import ConfiguredModel
from pydantic import Field

from src.api.models.ConfiguredModel import ConfiguredModel


class LeagueLeaderboard(ConfiguredModel):
technical_name: str = Field(alias="technicalName")
5 changes: 3 additions & 2 deletions src/api/models/LeagueSeason.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from api.models.ConfiguredModel import ConfiguredModel
from api.models.LeagueLeaderboard import LeagueLeaderboard
from pydantic import Field

from src.api.models.ConfiguredModel import ConfiguredModel
from src.api.models.LeagueLeaderboard import LeagueLeaderboard


class LeagueSeason(ConfiguredModel):
end_date: str = Field(alias="endDate")
Expand Down
7 changes: 4 additions & 3 deletions src/api/models/LeagueSeasonScore.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from api.models.ConfiguredModel import ConfiguredModel
from api.models.LeagueSeason import LeagueSeason
from api.models.LeagueSubdivision import LeagueSubdivision
from pydantic import Field

from src.api.models.ConfiguredModel import ConfiguredModel
from src.api.models.LeagueSeason import LeagueSeason
from src.api.models.LeagueSubdivision import LeagueSubdivision


class LeagueSeasonScore(ConfiguredModel):
game_count: int = Field(alias="gameCount")
Expand Down
5 changes: 3 additions & 2 deletions src/api/models/LeagueSubdivision.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from api.models.ConfiguredModel import ConfiguredModel
from api.models.LeagueDivision import LeagueDivision
from pydantic import Field

from src.api.models.ConfiguredModel import ConfiguredModel
from src.api.models.LeagueDivision import LeagueDivision


class LeagueSubdivision(ConfiguredModel):
index: int = Field(alias="subdivisionIndex")
Expand Down
Loading

0 comments on commit 21f23b6

Please sign in to comment.