-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating objects and parsing with dummy data file
- Loading branch information
Showing
5 changed files
with
59 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Client: | ||
|
||
def __init__(self, callsign, vid, client_type, frequency=None): | ||
self.callsign = callsign | ||
self.vid = vid | ||
self.client_type = client_type | ||
self.frequency = frequency | ||
|
||
def __str__(self): | ||
return "{0} as {1} with {2} callsign".format(self.vid, self.client_type, self.callsign) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from .Client import Client | ||
|
||
|
||
class Parser: | ||
|
||
def __init__(self): | ||
with open('whazzup.2.txt') as file: | ||
self.content = file.read() | ||
self.clients = self.content.split('!CLIENTS\n')[1].split('!AIRPORTS')[0].split('\n')[:-1] | ||
|
||
def get_raw_data(self): | ||
return self.content | ||
|
||
def get_clients_object(self): | ||
users = [] | ||
for client in self.clients: | ||
data = client.split(':') | ||
users.append(Client(callsign=data[0], vid=data[1], client_type=data[3], frequency=data[4])) | ||
return users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from .Parser import Parser | ||
|
||
|
||
class Server: | ||
clients = [] | ||
controllers = [] | ||
pilots = [] | ||
folme = [] | ||
|
||
def __init__(self): | ||
self.update_data() | ||
|
||
def update_data(cls): | ||
parser = Parser() | ||
for client in parser.get_clients_object(): | ||
if client not in cls.clients: | ||
cls.clients.append(client) | ||
if client.client_type == "ATC": | ||
cls.controllers.append(client) | ||
elif client.client_type == "PILOT": | ||
cls.pilots.append(client) | ||
else: | ||
cls.folme.append(client) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .Server import * | ||
from .Parser import * | ||
from .Client import * |