123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- def find_username_id(username, file_path="username_id"):
- """Find the ID for a given username from the username_id file."""
- try:
- with open(file_path, "r", encoding="utf-8") as file:
- for line in file:
- if line.strip():
- user, user_id = line.strip().split(":")
- if user == username:
- return user_id
- print(f"Username '{username}' not found.")
- return None
- except FileNotFoundError:
- print(f"File not found: {file_path}")
- return None
- except Exception as e:
- print(f"An error occurred: {e}")
- return None
- def generate_evoluz_link(username_id, task_id, base_url):
- """Generate Evoluz link."""
- team_id = f"teamID={username_id}"
- update_team_id = f"updateTeamId={task_id}"
- return f"{base_url}{team_id}&{update_team_id}"
- def find_task_type(branch_name):
- """Extract branch type and task ID from branch name."""
- try:
- parts = branch_name.split("/")
- if len(parts) >= 2:
- branch_type = parts[0]
- task_id = parts[1].split("_")[0]
- return {"task_type": branch_type, "task_id": task_id}
- else:
- print(f"Invalid branch name format: {branch_name}")
- return None
- except Exception as e:
- print(f"Error extracting task type: {e}")
- return None
- def find_squad(username):
- """Find the squad for a given username from the username_squad file."""
- file_path = "username_squad"
- try:
- with open(file_path, "r", encoding="utf-8") as file:
- for line in file:
- if line.strip():
- user, squad = line.strip().split(":")
- if user.lower() == username.lower():
- return squad.lower()
- print(f"Username '{username}' not found in squad file.")
- return None
- except FileNotFoundError:
- print(f"Squad file not found: {file_path}")
- return None
- except Exception as e:
- print(f"An error occurred while finding squad: {e}")
- return None
|