instruction stringclasses 100
values | code stringlengths 78 193k | response stringlengths 259 170k | file stringlengths 59 203 |
|---|---|---|---|
Help me document legacy Python code | # Copyright 2021-2024 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-many-arguments,too-many-locals
from __future__ import annotations
import typing
import logging
import os
import multiprocessing
import queue
import sys
from openage.convert.entity_object.export.texture import Texture
fro... | --- +++ @@ -1,6 +1,9 @@ # Copyright 2021-2024 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-many-arguments,too-many-locals
+"""
+Converts media requested by export requests to files.
+"""
from __future__ import annotations
import typing
@@ -29,6 +32,11 @@
class MediaExporter:
+ ... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/processor/export/media_exporter.py |
Write Python docstrings for this snippet | # Copyright 2020-2022 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-few-public-methods
from __future__ import annotations
import typing
from ....log import info
from .data_exporter import DataExporter
from .generate_manifest_hashes import generate_hashes
from .media_exporter import Media... | --- +++ @@ -1,6 +1,9 @@ # Copyright 2020-2022 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-few-public-methods
+"""
+Export data from a modpack to files.
+"""
from __future__ import annotations
import typing
@@ -17,9 +20,20 @@
class ModpackExporter:
+ """
+ Writes the conte... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/processor/export/modpack_exporter.py |
Document functions with detailed explanations | # Copyright 2021-2022 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-few-public-methods
from __future__ import annotations
import typing
if typing.TYPE_CHECKING:
from openage.util.fslike.directory import Directory
from openage.convert.entity_object.export.data_definition import D... | --- +++ @@ -1,6 +1,9 @@ # Copyright 2021-2022 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-few-public-methods
+"""
+Exports data formats from a modpack to files.
+"""
from __future__ import annotations
import typing
@@ -12,13 +15,25 @@
class DataExporter:
+ """
+ Writes th... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/processor/export/data_exporter.py |
Generate documentation strings for clarity | # Copyright 2015-2024 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-many-return-statements
from __future__ import annotations
import typing
import timeit
from ...log import info, dbg
from ..processor.export.modpack_exporter import ModpackExporter
from ..service.debug_info import debug_g... | --- +++ @@ -2,6 +2,10 @@ #
# pylint: disable=too-many-return-statements
+"""
+Receives cleaned-up srcdir and targetdir objects from .main, and drives the
+actual conversion process.
+"""
from __future__ import annotations
import typing
import timeit
@@ -24,6 +28,10 @@
def convert(args: Namespace) -> None:
+ ... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/tool/driver.py |
Add docstrings including usage examples | # Copyright 2016-2023 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
from ....entity_object.export.texture import TextureImage
from ....value_object.read.media.hardcoded.interface import (TOP_STRIP_PATTERN_CORNERS,
... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2016-2023 the openage authors. See copying.md for legal info.
+"""
+Cutting some user interface assets into subtextures.
+"""
from __future__ import annotations
import typing
@@ -19,11 +22,17 @@
class InterfaceCutter:
+ """
+ Cuts interface textures into repeatable pa... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/service/export/interface/cutter.py |
Write docstrings describing functionality | # Copyright 2024-2024 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
from itertools import chain
from openage.util.version import SemanticVersion
from ....log import info
from ..init.version_detect import create_version_objects
if typing.TYPE_CHECKING:
fr... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2024-2024 the openage authors. See copying.md for legal info.
+"""
+Check for updates in the openage converter modpacks.
+"""
from __future__ import annotations
import typing
@@ -17,6 +20,13 @@
def check_updates(available_modpacks: dict[str, str], game_info_dir: UnionPath):... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/service/init/changelog.py |
Write documentation strings for class attributes | # Copyright 2023-2024 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
import toml
from ....log import info, dbg
if typing.TYPE_CHECKING:
from openage.util.fslike.union import UnionPath
def enumerate_modpacks(modpacks_dir: UnionPath, exclude: set[str] = None... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2023-2024 the openage authors. See copying.md for legal info.
+"""
+Search for and enumerate openage modpacks.
+"""
from __future__ import annotations
import typing
@@ -12,6 +15,16 @@
def enumerate_modpacks(modpacks_dir: UnionPath, exclude: set[str] = None) -> dict[str, str... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/service/init/modpack_search.py |
Add docstrings to incomplete code | # Copyright 2020-2023 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-many-branches
from __future__ import annotations
import typing
from ....util.fslike.union import Union
from ...value_object.read.media.drs import DRS
if typing.TYPE_CHECKING:
from openage.convert.value_object.init.g... | --- +++ @@ -1,6 +1,9 @@ # Copyright 2020-2023 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-many-branches
+"""
+Mount asset dirs of a game version into the conversion folder.
+"""
from __future__ import annotations
import typing
@@ -17,11 +20,18 @@ srcdir: Directory,
game_ve... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/service/init/mount_asset_dirs.py |
Help me write clear docstrings | # Copyright 2020-2024 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches
from __future__ import annotations
import typing
import toml
from ....log import info, warn, dbg
from ....util.hash import hash_file
from ...value_object.init.game_vers... | --- +++ @@ -1,6 +1,9 @@ # Copyright 2020-2024 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches
+"""
+Detects the base version of the game and installed expansions.
+"""
from __future__ import annotations
@@ -23,6 +26,10 @@ avail_game... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/service/init/version_detect.py |
Create docstrings for reusable components | # Copyright 2020-2024 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-many-branches
from __future__ import annotations
import platform
import typing
from configparser import ConfigParser
import os
from pathlib import Path
import subprocess
import sys
from typing import AnyStr, Generator
i... | --- +++ @@ -2,6 +2,9 @@ #
# pylint: disable=too-many-branches
+"""
+Acquire the sourcedir for the game that is supposed to be converted.
+"""
from __future__ import annotations
import platform
import typing
@@ -39,10 +42,18 @@
def expand_relative_path(path: str) -> AnyStr:
+ """Expand relative path to an a... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/tool/subtool/acquire_sourcedir.py |
Document my Python code with docstrings | # Copyright 2020-2023 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-many-branches
from __future__ import annotations
import typing
from ...value_object.read.media.colortable import ColorTable
from ...value_object.read.media_types import MediaType
if typing.TYPE_CHECKING:
from openag... | --- +++ @@ -2,6 +2,9 @@ #
# pylint: disable=too-many-branches
+"""
+Module for reading palette files.
+"""
from __future__ import annotations
import typing
@@ -18,6 +21,9 @@ game_version: GameVersion,
index: int = None
) -> dict[int, ColorTable]:
+ """
+ Read and create the color palettes.
+ "... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/service/read/palette.py |
Expand my code with proper documentation strings | # Copyright 2013-2023 the openage authors. See copying.md for legal info.
# TODO pylint: disable=C,R
from __future__ import annotations
import typing
from functools import cache
from . import civ
from . import graphic
from . import maps
from . import playercolor
from . import research
from . import sound
from . impo... | --- +++ @@ -34,6 +34,11 @@ # documentation for this can be found in `doc/gamedata`
# the binary structure, which the dat file has, is in `doc/gamedata.struct`
class EmpiresDat(GenieStructure):
+ """
+ class for fighting and beating the compressed empires2*.dat
+
+ represents the main game data file.
+ """... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media/datfile/empiresdat.py |
Generate docstrings for exported functions | # Copyright 2013-2023 the openage authors. See copying.md for legal info.
# TODO pylint: disable=too-many-function-args
from __future__ import annotations
import typing
from math import sqrt
from struct import Struct, unpack_from
import numpy
from .....log import dbg
from ..genie_structure import GenieStructure
... | --- +++ @@ -2,6 +2,12 @@
# TODO pylint: disable=too-many-function-args
+"""
+Conversion for the terrain blending masks.
+Those originate from blendomatic.dat.
+
+For more information, see doc/media/blendomatic.md
+"""
from __future__ import annotations
import typing
@@ -25,6 +31,10 @@
class BlendingTile:
+ ... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media/blendomatic.py |
Create documentation strings for testing functions | # Copyright 2013-2023 the openage authors. See copying.md for legal info.
# TODO pylint: disable=C,R,too-many-function-args
from __future__ import annotations
import typing
import math
import numpy
from .....log import dbg
from ..genie_structure import GenieStructure
if typing.TYPE_CHECKING:
from PIL import I... | --- +++ @@ -94,6 +94,9 @@ return f"{repr(self)}\n{self.palette}"
def gen_image(self, draw_text: bool = True, squaresize: int = 100) -> Image:
+ """
+ writes this color table (palette) to a png image.
+ """
from PIL import Image, ImageDraw
@@ -164,6 +167,9 @@ cls,... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media/colortable.py |
Create documentation for each function signature | # Copyright 2014-2023 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
import re
from ....log import dbg
from ...entity_object.conversion.stringresource import StringResource
from ...value_object.read.media.langcodes import LANGCODES_DE1, LANGCODES_DE2, LANGCODES... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2014-2023 the openage authors. See copying.md for legal info.
+"""
+Module for reading plaintext-based language files.
+"""
from __future__ import annotations
import typing
@@ -22,6 +25,7 @@
def get_string_resources(args: Namespace) -> StringResource:
+ """ reads the (la... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/service/read/string_resource.py |
Annotate my code with docstrings | # Copyright 2013-2024 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
from .....log import spam, dbg
from .....util.filelike.stream import StreamFragment
from .....util.fslike.filecollection import FileCollection, FileEntry
from .....util.strings import decode_unt... | --- +++ @@ -1,5 +1,11 @@ # Copyright 2013-2024 the openage authors. See copying.md for legal info.
+"""
+Code for reading Genie .DRS archives.
+
+Note that .DRS archives can't store file names; they just store the file
+extension, and a file number.
+"""
from __future__ import annotations
import typing
@@ -22,6 +... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media/drs.py |
Add detailed docstrings explaining each function | # Copyright 2013-2024 the openage authors. See copying.md for legal info.
# TODO pylint: disable=C,R,too-many-lines
from __future__ import annotations
import typing
from functools import cache
from ...genie_structure import GenieStructure
from ....read.member_access import READ, READ_GEN, SKIP
from ....read.read_mem... | --- +++ @@ -24,13 +24,20 @@
class UnitCommand(GenieStructure):
-
- @classmethod
- @cache
- def get_data_format_members(
- cls,
- game_version: GameVersion
- ) -> list[tuple[MemberAccess, str, StorageType, typing.Union[str, ReadMember]]]:
+ """
+ also known as "Task" according to ES d... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media/datfile/unit.py |
Turn comments into proper docstrings | # Copyright 2019-2023 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
if typing.TYPE_CHECKING:
from openage.convert.entity_object.conversion.converter_object import ConverterObjectGroup, \
RawAPIObject
from openage.nyan.nyan_structs import NyanObj... | --- +++ @@ -1,5 +1,11 @@ # Copyright 2019-2023 the openage authors. See copying.md for legal info.
+"""
+Forward references point to an object that is not created yet.
+This can be utilized to avoid cyclic dependencies like A->B
+while B->A during conversion. The pointer can be resolved
+once the object has been crea... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/conversion/forward_ref.py |
Write docstrings for backend logic | # Copyright 2013-2023 the openage authors. See copying.md for legal info.
# TODO pylint: disable=C,R
from __future__ import annotations
import typing
from functools import cache
from ...genie_structure import GenieStructure
from ....read.member_access import READ, READ_GEN, SKIP
from ....read.read_members import Arr... | --- +++ @@ -25,6 +25,9 @@ cls,
game_version: GameVersion
) -> list[tuple[MemberAccess, str, StorageType, typing.Union[str, ReadMember]]]:
+ """
+ Return the members in this struct.
+ """
data_format = [
(READ_GEN, "frame_count", StorageType.INT_MEMBER, "i... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media/datfile/terrain.py |
Help me write clear docstrings | # Copyright 2020-2023 the openage authors. See copying.md for legal info.
class GameFileVersion:
hash_algo = "SHA3-256"
def __init__(self, filepaths: list[str], hashes: dict[str, str]):
self.paths = filepaths
if len(self.paths) < 1:
raise ValueError(f"{self}: List of paths cannot... | --- +++ @@ -1,11 +1,29 @@ # Copyright 2020-2023 the openage authors. See copying.md for legal info.
+"""
+Associate files or filepaths with hash values to determine the exact version of a game.
+"""
class GameFileVersion:
+ """
+ Associates a file hash with a specific version number.
+ This can be used ... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/init/game_file_version.py |
Replace inline comments with docstrings | # Copyright 2014-2024 the openage authors. See copying.md for legal info.
# TODO pylint: disable=C,R
from __future__ import annotations
import typing
import math
import re
import struct
from openage.convert.value_object.read.dynamic_loader import DynamicLoader
from ....util.strings import decode_until_null
from .m... | --- +++ @@ -59,6 +59,9 @@
class GenieStructure:
+ """
+ superclass for all structures from Genie Engine games.
+ """
dynamic_load = False
@@ -75,6 +78,11 @@ members: tuple = None,
dynamic_load = False
) -> tuple[int, list[ValueMember]]:
+ """
+ recursively read ... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/genie_structure.py |
Auto-generate documentation strings for this file | # Copyright 2015-2017 the openage authors. See copying.md for legal info.
from ..util.decorators import run_once
from ..log import dbg
from ..log.log_cpp import enable_log_translation
@run_once
def setup(args):
dbg("initializing libopenage...")
# this is where calls to the setup methods of all other modu... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2015-2017 the openage authors. See copying.md for legal info.
+"""
+Contains the function that initializes the C++ interface.
+"""
from ..util.decorators import run_once
@@ -10,6 +13,19 @@
@run_once
def setup(args):
+ """
+ After a call to setup(), the C++ interface i... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/cppinterface/setup.py |
Document this code for team use | # Copyright 2013-2024 the openage authors. See copying.md for legal info.
# TODO pylint: disable=C,R
from __future__ import annotations
import typing
from functools import cache
from ...genie_structure import GenieStructure
from ....read.member_access import READ, READ_GEN, SKIP
from ....read.read_members import Sub... | --- +++ @@ -26,6 +26,9 @@ cls,
game_version: GameVersion
) -> list[tuple[MemberAccess, str, StorageType, typing.Union[str, ReadMember]]]:
+ """
+ Return the members in this struct.
+ """
data_format = [
(READ_GEN, "type_id", StorageType.ID_MEMBER, EnumLoo... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media/datfile/tech.py |
Add docstrings following best practices | # Copyright 2015-2023 the openage authors. See copying.md for legal info.
# TODO pylint: disable=C,R
from __future__ import annotations
import typing
from functools import cache
from ...genie_structure import GenieStructure
from ....read.member_access import READ, SKIP
from ....read.read_members import SubdataMember... | --- +++ @@ -25,6 +25,9 @@ cls,
game_version: GameVersion
) -> list[tuple[MemberAccess, str, StorageType, typing.Union[str, ReadMember]]]:
+ """
+ Return the members in this struct.
+ """
data_format = [
(READ, "map_id", StorageType.ID_MEMBER, "int32_t"),
... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media/datfile/maps.py |
Create structured documentation for my script | # Copyright 2014-2022 the openage authors. See copying.md for legal info.
# TODO pylint: disable=C,R
from __future__ import annotations
import typing
if typing.TYPE_CHECKING:
from openage.convert.value_object.read.genie_structure import GenieStructure
from openage.convert.value_object.init.game_version impo... | --- +++ @@ -2,6 +2,9 @@
# TODO pylint: disable=C,R
+"""
+Dynamically load and unload data from a file at runtime.
+"""
from __future__ import annotations
import typing
@@ -13,6 +16,10 @@
class DynamicLoader:
+ """
+ Member that can be loaded and unloaded at runtime, saving
+ memory in the process.
... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/dynamic_loader.py |
Add structured docstrings to improve clarity | # Copyright 2020-2020 the openage authors. See copying.md for legal info.
from enum import Enum
class MediaType(Enum):
DATFILE = "data"
GAMEDATA = "gamedata"
GRAPHICS = "graphics"
INTERFACE = "interface"
LANGUAGE = "language"
PALETTES = "palettes"
TERRAIN = "terrain"
SOUNDS ... | --- +++ @@ -1,10 +1,17 @@ # Copyright 2020-2020 the openage authors. See copying.md for legal info.
+"""
+Media types used in games. Media types refer to a group
+of file types used in the game.
+"""
from enum import Enum
class MediaType(Enum):
+ """
+ A type of media. Stores the mount point as the valu... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media_types.py |
Generate docstrings for script automation | # Copyright 2016-2022 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
from ..log import info, spam
if typing.TYPE_CHECKING:
from openage.util.fslike.path import Path
def load_config_file(path: Path, set_cvar_func: typing.Callable, loaded_files: set = None)... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2016-2022 the openage authors. See copying.md for legal info.
+"""
+Load and save the configuration : file <-> console var system
+"""
from __future__ import annotations
import typing
@@ -12,6 +15,12 @@
def load_config_file(path: Path, set_cvar_func: typing.Callable, loaded... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/cvar/config_file.py |
Write docstrings describing functionality | # Copyright 2014-2023 the openage authors. See copying.md for legal info.
#
# TODO pylint: disable=C,R,abstract-method
from __future__ import annotations
import typing
from enum import Enum
if typing.TYPE_CHECKING:
from openage.convert.value_object.read.genie_structure import GenieStructure
from openage.con... | --- +++ @@ -15,6 +15,12 @@
class ReadMember:
+ """
+ member variable of data files and generated structs.
+
+ equals:
+ * data field in the .dat file
+ """
def __init__(self):
self.length = 1
@@ -22,9 +28,17 @@ self.do_raw_read = True
def entry_hook(self, data: typing.A... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/read_members.py |
Insert docstrings into my code | # Copyright 2015-2022 the openage authors. See copying.md for legal info.
from collections import deque
from bisect import bisect
from typing import Generator
class ByteQueue:
def __init__(self):
self.bufs = deque()
# stores the amount of data that's currently available.
self.size = 0
... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2015-2022 the openage authors. See copying.md for legal info.
+"""
+Provides ByteQueue, a high-performance queue for bytes objects.
+"""
from collections import deque
from bisect import bisect
@@ -7,6 +10,25 @@
class ByteQueue:
+ """
+ Queue for bytes
+ Can append ... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/bytequeue.py |
Add docstrings for better understanding | # Copyright 2019-2023 the openage authors. See copying.md for legal info.
# TODO pylint: disable=C,R,abstract-method
from __future__ import annotations
import typing
from enum import Enum
from math import isclose
from abc import ABC, abstractmethod
from .dynamic_loader import DynamicLoader
class ValueMember(ABC):... | --- +++ @@ -1,6 +1,26 @@ # Copyright 2019-2023 the openage authors. See copying.md for legal info.
# TODO pylint: disable=C,R,abstract-method
+"""
+Storage format for values from data file entries.
+Data from ReadMembers is supposed to be transferred
+to these objects for easier handling during the conversion
+proce... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/value_members.py |
Document all endpoints with docstrings | # Copyright 2013-2023 the openage authors. See copying.md for legal info.
# TODO pylint: disable=C,R
from __future__ import annotations
import typing
from functools import cache
from ...genie_structure import GenieStructure
from ....read.member_access import READ_GEN, READ, SKIP
from ....read.read_members import Sub... | --- +++ @@ -25,6 +25,9 @@ cls,
game_version: GameVersion
) -> list[tuple[MemberAccess, str, StorageType, typing.Union[str, ReadMember]]]:
+ """
+ Return the members in this struct.
+ """
data_format = []
if game_version.edition.game_id in ("AOE1DE", "AOE2DE... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media/datfile/sound.py |
Help me document legacy Python code | # Copyright 2020-2024 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-many-arguments
from __future__ import annotations
from dataclasses import dataclass
import enum
from ..read.media_types import MediaType
from .game_file_version import GameFileVersion
@enum.unique
class Support(enum.E... | --- +++ @@ -2,6 +2,9 @@ #
# pylint: disable=too-many-arguments
+"""
+Stores information about base game editions and expansions.
+"""
from __future__ import annotations
from dataclasses import dataclass
@@ -13,12 +16,18 @@
@enum.unique
class Support(enum.Enum):
+ """
+ Support state of a game version
+ ... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/init/game_version.py |
Document functions with clear intent | # Copyright 2013-2023 the openage authors. See copying.md for legal info.
# TODO pylint: disable=C,R
from __future__ import annotations
import typing
from functools import cache
from ...genie_structure import GenieStructure
from ....read.member_access import READ, READ_GEN, SKIP
from ....read.read_members import Sub... | --- +++ @@ -26,6 +26,9 @@ cls,
game_version: GameVersion
) -> list[tuple[MemberAccess, str, StorageType, typing.Union[str, ReadMember]]]:
+ """
+ Return the members in this struct.
+ """
data_format = [
(READ_GEN, "type_id", StorageType.ID_MEMBER, EnumLoo... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media/datfile/research.py |
Generate docstrings for exported functions | # Copyright 2014-2021 the openage authors. See copying.md for legal info.
import logging
from os import environ
from ..util.math import clamp
PYTHON_TO_CPP_LOG_LEVEL = {}
class CppHandler(logging.Handler):
def __init__(self):
super().__init__()
def setLevel(self, level):
cpp_level = PYTH... | --- +++ @@ -1,5 +1,11 @@ # Copyright 2014-2021 the openage authors. See copying.md for legal info.
+"""
+Python logging.
+
+Log messages get redirected to the CPP logging system if the library has been
+loaded.
+"""
import logging
from os import environ
@@ -10,11 +16,15 @@
class CppHandler(logging.Handler):
+... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/log/__init__.py |
Help me comply with documentation standards | # Copyright 2017-2023 the openage authors. See copying.md for legal info.
import os
import pathlib
import sys
# TODO: use os.pathsep for multipath variables
# Linux-specific dirs according to the freedesktop basedir standard:
# https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
#
# concretely:
... | --- +++ @@ -1,5 +1,11 @@ # Copyright 2017-2023 the openage authors. See copying.md for legal info.
+"""
+
+Code for locating the game assets.
+
+All access to game assets should happen through objects obtained from get().
+"""
import os
import pathlib
@@ -38,6 +44,10 @@
def get_dir(which):
+ """
+ Retur... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/default_dirs.py |
Generate NumPy-style docstrings | # Copyright 2017-2022 the openage authors. See copying.md for legal info.
import os
import pathlib
from .. import config, default_dirs
from ..util.fslike.directory import Directory
from ..util.fslike.union import Union
from ..util.fslike.wrapper import WriteBlocker
def get_config_path(custom_cfg_dir: str = None) -... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2017-2022 the openage authors. See copying.md for legal info.
+"""
+Determine the config file location and set up mounts.
+"""
import os
import pathlib
@@ -11,6 +14,10 @@
def get_config_path(custom_cfg_dir: str = None) -> Directory:
+ """
+ Locates the main configurat... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/cvar/location.py |
Create docstrings for API functions | # Copyright 2015-2024 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-many-locals
from __future__ import annotations
import typing
from ..log import info
if typing.TYPE_CHECKING:
from argparse import ArgumentParser
def init_subparser(cli: ArgumentParser) -> None:
cli.set_defaul... | --- +++ @@ -2,6 +2,9 @@ #
# pylint: disable=too-many-locals
+"""
+Holds the game entry point for openage.
+"""
from __future__ import annotations
import typing
@@ -13,6 +16,7 @@
def init_subparser(cli: ArgumentParser) -> None:
+ """ Initializes the parser for game-specific args. """
cli.set_defaults(... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/game/main.py |
Add docstrings for internal functions | # Copyright 2015-2024 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
from ..log import info
if typing.TYPE_CHECKING:
from argparse import ArgumentParser
def init_subparser(cli: ArgumentParser):
cli.set_defaults(entrypoint=main)
cli.add_argument(
... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2015-2024 the openage authors. See copying.md for legal info.
+"""
+Main engine entry point for openage.
+"""
from __future__ import annotations
import typing
@@ -10,6 +13,7 @@
def init_subparser(cli: ArgumentParser):
+ """ Initializes the parser for game-specific args. ... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/main/main.py |
Help me add docstrings to my project | # Copyright 2015-2024 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
from collections import OrderedDict
from io import UnsupportedOperation
from typing import NoReturn
from .abstract import FSLikeObject
from .path import Path
if typing.TYPE_CHECKING:
from o... | --- +++ @@ -1,5 +1,9 @@ # Copyright 2015-2024 the openage authors. See copying.md for legal info.
+"""
+Provides Filecollection, a utility class for combining multiple file-like
+objects to a FSLikeObject.
+"""
from __future__ import annotations
import typing
@@ -15,6 +19,11 @@
class FileCollection(FSLikeObje... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/fslike/filecollection.py |
Provide clean and structured docstrings | # Copyright 2019-2022 the openage authors. See copying.md for legal info.
from typing import Generic, Hashable, TypeVar
OrderedSetItem = TypeVar("OrderedSetItem")
class OrderedSet(Generic[OrderedSetItem]):
__slots__ = ('ordered_set',)
def __init__(self, elements: Hashable = None):
self.ordered_s... | --- +++ @@ -1,5 +1,10 @@ # Copyright 2019-2022 the openage authors. See copying.md for legal info.
+"""
+Provides a very simple implementation of an ordered set. We use the
+Python dictionaries as a basis because they are guaranteed to
+be ordered since Python 3.6.
+"""
from typing import Generic, Hashable, Type... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/ordered_set.py |
Write beginner-friendly docstrings | # Copyright 2017-2022 the openage authors. See copying.md for legal info.
import os
from io import UnsupportedOperation
from typing import NoReturn
from .abstract import FileLikeObject
from ..bytequeue import ByteQueue
class FIFO(FileLikeObject):
def __init__(self):
super().__init__()
self.eof... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2017-2022 the openage authors. See copying.md for legal info.
+"""
+Provides a FileLikeObject that acts like a FIFO.
+"""
import os
from io import UnsupportedOperation
@@ -10,6 +13,21 @@
class FIFO(FileLikeObject):
+ """
+ File-like wrapper around ByteQueue.
+
+ Da... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/filelike/fifo.py |
Write documentation strings for class attributes | # Copyright 2015-2022 the openage authors. See copying.md for legal info.
from sys import stdout
def decode_until_null(data: bytes, encoding: str = 'utf-8') -> str:
end = data.find(0)
if end != -1:
data = data[:end]
return data.decode(encoding)
def try_decode(data: bytes) -> str:
try:
... | --- +++ @@ -1,9 +1,19 @@ # Copyright 2015-2022 the openage authors. See copying.md for legal info.
+"""
+Misc string helper functions; this includes encoding, decoding,
+manipulation, ...
+"""
from sys import stdout
def decode_until_null(data: bytes, encoding: str = 'utf-8') -> str:
+ """
+ decodes a byte... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/strings.py |
Insert docstrings into my code | # Copyright 2020-2023 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-few-public-methods
from __future__ import annotations
from typing import Any, Optional
import weakref
class Observer:
def update(self, observable: Observable, message: Optional[Any] = None):
raise NotImple... | --- +++ @@ -2,6 +2,18 @@ #
# pylint: disable=too-few-public-methods
+"""
+Implements the Observer design pattern. Observers can be
+notified when an object they observe (so-called Observable)
+changes.
+
+The implementation is modelled after the Java 8 specification
+of Observable and Observer.
+
+Observer reference... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/observer.py |
Add standardized docstrings across the file | # Copyright 2015-2023 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
from collections import defaultdict
from .....util.filelike.stream import StreamFragment
from .....util.struct import NamedStruct
from .langcodes import LANGCODES_AOC
if typing.TYPE_CHECKING:... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2015-2023 the openage authors. See copying.md for legal info.
+"""
+Provides PEResources, which reads the resource section from a PEFile.
+"""
from __future__ import annotations
import typing
@@ -50,6 +53,9 @@
class ResourceDirectory(NamedStruct):
+ """
+ Resource dir... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media/peresource.py |
Document this script properly | # Copyright 2015-2022 the openage authors. See copying.md for legal info.
from typing import Callable
def run_once(func: Callable) -> Callable:
def wrapper(*args, **kwargs):
if wrapper.has_run:
return None
wrapper.has_run = True
return func(*args, **kwargs)
wrapper.ha... | --- +++ @@ -1,13 +1,22 @@ # Copyright 2015-2022 the openage authors. See copying.md for legal info.
+"""
+Some utility function decorators
+"""
from typing import Callable
def run_once(func: Callable) -> Callable:
+ """
+ Decorator to run func only at its first invocation.
+
+ Set func.has_run to F... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/decorators.py |
Add missing documentation to my Python functions | # Copyright 2013-2023 the openage authors. See copying.md for legal info.
# TODO pylint: disable=C,R
from __future__ import annotations
import typing
from functools import cache
from ...genie_structure import GenieStructure
from ....read.member_access import READ, READ_GEN, SKIP
from ....read.read_members import Sub... | --- +++ @@ -26,6 +26,9 @@ cls,
game_version: GameVersion
) -> list[tuple[MemberAccess, str, StorageType, typing.Union[str, ReadMember]]]:
+ """
+ Return the members in this struct.
+ """
data_format = [
(READ_GEN, "graphic_id", StorageType.ID_MEMBER, "int... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media/datfile/graphic.py |
Add missing documentation to my Python functions | # Copyright 2020-2023 the openage authors. See copying.md for legal info.
from __future__ import annotations
from enum import Enum
import typing
from openage.log import warn
if typing.TYPE_CHECKING:
from openage.convert.entity_object.export.formats.nyan_file import NyanFile
from openage.nyan.nyan_structs imp... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2020-2023 the openage authors. See copying.md for legal info.
+"""
+Tree structure for resolving imports.
+"""
from __future__ import annotations
from enum import Enum
import typing
@@ -12,6 +15,9 @@
class NodeType(Enum):
+ """
+ Types for nodes.
+ """
ROOT ... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/nyan/import_tree.py |
Add docstrings for internal functions | # Copyright 2019-2023 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-many-lines,too-many-arguments,too-many-return-statements,too-many-locals
from __future__ import annotations
import typing
from enum import Enum
import re
from ..util.ordered_set import OrderedSet
if typing.TYPE_CHECKI... | --- +++ @@ -2,6 +2,17 @@ #
# pylint: disable=too-many-lines,too-many-arguments,too-many-return-statements,too-many-locals
+"""
+Nyan structs.
+
+Simple implementation to store nyan objects and
+members for usage in the converter. This is not
+a real nyan^TM implementation, but rather a "dumb"
+storage format.
+
+Pyt... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/nyan/nyan_structs.py |
Document my Python code with docstrings | # Copyright 2015-2024 the openage authors. See copying.md for legal info.
from collections import OrderedDict
from struct import Struct
from ..util.files import read_guaranteed
class NamedStructMeta(type):
@classmethod
def __prepare__(mcs, name, bases, **kwds):
del mcs, name, bases, kwds # unused... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2015-2024 the openage authors. See copying.md for legal info.
+"""
+Provides some classes designed to expand the functionality of struct.struct
+"""
from collections import OrderedDict
@@ -9,6 +12,12 @@
class NamedStructMeta(type):
+ """
+ Metaclass for NamedStruct.
... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/struct.py |
Generate docstrings for script automation | # Copyright 2013-2023 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
from .....util.filelike.stream import StreamFragment
from .....util.struct import NamedStruct
if typing.TYPE_CHECKING:
from openage.convert.value_object.read.media.peresource import PEResou... | --- +++ @@ -1,5 +1,12 @@ # Copyright 2013-2023 the openage authors. See copying.md for legal info.
+"""
+Provides PEFile, a class for reading MS portable executable files.
+
+Primary doc sources:
+http://www.csn.ul.ie/~caolan/pub/winresdump/winresdump/doc/pefile2.html
+http://en.wikibooks.org/wiki/X86_Disassembly/Win... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/convert/value_object/read/media/pefile.py |
Create structured documentation for my script | # Copyright 2015-2022 the openage authors. See copying.md for legal info.
from abc import ABC, abstractmethod
from io import UnsupportedOperation
import os
class FileLikeObject(ABC):
def __init__(self):
self.closed = False
@abstractmethod
def read(self, size: int = -1) -> bytes:
@abstract... | --- +++ @@ -1,5 +1,9 @@ # Copyright 2015-2022 the openage authors. See copying.md for legal info.
+"""
+Provides the FileLikeObject abstract base class, which specifies a file-like
+interface, and various classes that implement the interface.
+"""
from abc import ABC, abstractmethod
from io import UnsupportedOper... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/filelike/abstract.py |
Write docstrings for utility functions | # Copyright 2015-2022 the openage authors. See copying.md for legal info.
import os
from threading import Lock
from ..context import DummyGuard
from ..filelike.abstract import FileLikeObject
from .abstract import FSLikeObject, ReadOnlyFSLikeObject
from .path import Path
class Wrapper(FSLikeObject):
def __ini... | --- +++ @@ -1,5 +1,15 @@ # Copyright 2015-2022 the openage authors. See copying.md for legal info.
+"""
+Provides
+
+ - Wrapper, a utility class for implementing wrappers around FSLikeObject.
+ - WriteBlocker, a wrapper that blocks all writing.
+ - Synchronizer, which adds thread-safety to a FSLikeObject
+ ... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/fslike/wrapper.py |
Add docstrings with type hints explained | # Copyright 2015-2022 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
from abc import ABC, abstractmethod
from io import UnsupportedOperation
from .path import Path
if typing.TYPE_CHECKING:
from io import BufferedReader
class FSLikeObject(ABC):
# sorry... | --- +++ @@ -1,5 +1,16 @@ # Copyright 2015-2022 the openage authors. See copying.md for legal info.
+"""
+Provides filesystem-like interfaces:
+
+ - FileSystemLikeObject (abstract class)
+ an abstract class for objects that represent file systems.
+
+ - ReadOnlyFileSystemLikeObject (abstract class)
+ implements ... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/fslike/abstract.py |
Document functions with detailed explanations | # Copyright 2015-2023 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
import os
from typing import Union
if typing.TYPE_CHECKING:
from openage.util.fslike.abstract import FSLikeObject
def read_guaranteed(fileobj: FSLikeObject, size: int) -> bytes:
remain... | --- +++ @@ -1,4 +1,7 @@ # Copyright 2015-2023 the openage authors. See copying.md for legal info.
+"""
+Some file handling utilities
+"""
from __future__ import annotations
@@ -11,6 +14,10 @@
def read_guaranteed(fileobj: FSLikeObject, size: int) -> bytes:
+ """
+ As regular fileobj.read(size), but raises... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/files.py |
Create docstrings for all classes and functions | # Copyright 2017-2022 the openage authors. See copying.md for legal info.
import cProfile
import io
import pstats
import tracemalloc
class Profiler:
profile: cProfile.Profile = None
profile_stats: pstats.Stats = None
profile_stream = None
def __init__(self, o_stream=None):
# o_stream can b... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2017-2022 the openage authors. See copying.md for legal info.
+"""
+Profiling utilities
+"""
import cProfile
import io
@@ -8,6 +11,17 @@
class Profiler:
+ """
+ A class for quick and easy profiling.
+ Usage:
+ p = Profiler()
+ with p:
+ # c... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/profiler.py |
Add docstrings to improve code quality | # Copyright 2015-2022 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
from collections import OrderedDict
from .strings import colorize
from .math import INF
RULE_CACHE = OrderedDict()
if typing.TYPE_CHECKING:
from openage.util.fslike.abstract import FSLike... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2015-2022 the openage authors. See copying.md for legal info.
+"""
+Methods for printing paths and other file system-related info.
+"""
from __future__ import annotations
@@ -16,6 +19,9 @@
def get_color_rules() -> OrderedDict[str, str]:
+ """
+ Returns a dict of patt... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/fsprinting.py |
Document this script properly | # Copyright 2017-2022 the openage authors. See copying.md for legal info.
from ..math import INF, clamp
from .readonly import PosSavingReadOnlyFileLikeObject
from ..bytequeue import ByteBuffer
class StreamSeekBuffer(PosSavingReadOnlyFileLikeObject):
def __init__(self, wrappee, keepbuffered: int = INF, minread... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2017-2022 the openage authors. See copying.md for legal info.
+"""
+Provides FileLikeObject for binary stream interaction.
+"""
from ..math import INF, clamp
@@ -8,6 +11,28 @@
class StreamSeekBuffer(PosSavingReadOnlyFileLikeObject):
+ """
+ Wrapper file-like object t... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/filelike/stream.py |
Write docstrings for utility functions | # Copyright 2015-2023 the openage authors. See copying.md for legal info.
from __future__ import annotations
import typing
import os
import pathlib
from typing import Union
from .abstract import FSLikeObject
if typing.TYPE_CHECKING:
from io import BufferedReader
class Directory(FSLikeObject):
def __ini... | --- +++ @@ -1,5 +1,11 @@ # Copyright 2015-2023 the openage authors. See copying.md for legal info.
+"""
+FSLikeObjects that represent actual file system paths:
+
+ - Directory: enforces case
+ - CaseIgnoringReadOnlyDirectory
+"""
from __future__ import annotations
import typing
@@ -16,6 +22,11 @@
class Direct... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/fslike/directory.py |
Turn comments into proper docstrings | # Copyright 2015-2022 the openage authors. See copying.md for legal info.
import math
# I tend to use this all the time. I don't get why it's not in math.
INF = float("+inf")
# TAU for life!
TAU = 2 * math.pi
DEGSPERRAD = TAU / 360
def clamp(val: int, minval: int, maxval: int) -> int:
return min(maxval, max(m... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2015-2022 the openage authors. See copying.md for legal info.
+"""
+Holds some math constants and helpers
+"""
import math
@@ -12,4 +15,14 @@
def clamp(val: int, minval: int, maxval: int) -> int:
- return min(maxval, max(minval, val))+ """
+ clamps val to be at le... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/math.py |
Generate docstrings with parameter types | # Copyright 2015-2023 the openage authors. See copying.md for legal info.
from typing import NoReturn, Union
from io import UnsupportedOperation, TextIOWrapper
import os
import pathlib
import tempfile
class Path:
# We're re-implementing pathlib.Path's interface, we have no choice about
# this. Also, some o... | --- +++ @@ -1,5 +1,9 @@ # Copyright 2015-2023 the openage authors. See copying.md for legal info.
+"""
+Provides Path, which is analogous to pathlib.Path,
+and the type of FSLikeObject.root.
+"""
from typing import NoReturn, Union
from io import UnsupportedOperation, TextIOWrapper
@@ -9,6 +13,22 @@
class Path... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/fslike/path.py |
Write docstrings including parameters and return values | # Copyright 2015-2023 the openage authors. See copying.md for legal info.
from io import UnsupportedOperation
from .abstract import FSLikeObject
from .path import Path
class Union(FSLikeObject):
# we can hardly reduce the method amount...
# pylint: disable=too-many-public-methods
def __init__(self):
... | --- +++ @@ -1,5 +1,9 @@ # Copyright 2015-2023 the openage authors. See copying.md for legal info.
+"""
+Provides Union, a utility class for combining multiple FSLikeObjects to a
+single one.
+"""
from io import UnsupportedOperation
@@ -8,6 +12,14 @@
class Union(FSLikeObject):
+ """
+ FSLikeObject that ... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/fslike/union.py |
Generate docstrings for exported functions | # Copyright 2015-2021 the openage authors. See copying.md for legal info.
class DummyGuard:
# pylint: disable=too-few-public-methods
@staticmethod
def __enter__():
pass
@staticmethod
def __exit__(exc_type, exc_value, traceback):
pass | --- +++ @@ -1,8 +1,12 @@ # Copyright 2015-2021 the openage authors. See copying.md for legal info.
+"""
+Provides some utility context guards.
+"""
class DummyGuard:
+ """ Context guard that does nothing. """
# pylint: disable=too-few-public-methods
@staticmethod
@@ -11,4 +15,4 @@
@staticmet... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/context.py |
Document all public functions with docstrings | # Copyright 2017-2022 the openage authors. See copying.md for legal info.
import os
from io import UnsupportedOperation
from typing import NoReturn
from .abstract import FileLikeObject
class ReadOnlyFileLikeObject(FileLikeObject):
# pylint doesn't understand that this class is supposed to be abstract.
# p... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2017-2022 the openage authors. See copying.md for legal info.
+"""
+Provides an abstract read-only FileLikeObject.
+"""
import os
from io import UnsupportedOperation
@@ -9,6 +12,12 @@
class ReadOnlyFileLikeObject(FileLikeObject):
+ """
+ Most FileLikeObjects are read-... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/filelike/readonly.py |
Create documentation strings for testing functions | # Copyright 2024-2024 the openage authors. See copying.md for legal info.
from __future__ import annotations
import re
SEMVER_REGEX = re.compile(
(r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)"
r"(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)"
r"(?:\.(?:0|[1-9]\d*|... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2024-2024 the openage authors. See copying.md for legal info.
+"""
+Handling of version information for openage.
+"""
from __future__ import annotations
import re
@@ -12,8 +15,16 @@
class SemanticVersion:
+ """
+ Semantic versioning information.
+ """
def __... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/version.py |
Write docstrings for data processing functions | # Copyright 2024-2024 the openage authors. See copying.md for legal info.
import inspect
import os
import sys
# python.dll location
DEFAULT_PYTHON_DLL_DIR = os.path.dirname(sys.executable)
# openage.dll locations (relative to this file)
DEFAULT_OPENAGE_DLL_DIRs = [
"../../libopenage/Debug",
"../../libopenag... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2024-2024 the openage authors. See copying.md for legal info.
+"""
+Windows-specific loading of compiled Python modules and DLLs.
+"""
import inspect
import os
@@ -30,8 +33,19 @@
class DllDirectoryManager:
+ """
+ Manages directories that should be added to/removed fr... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/dll.py |
Add docstrings following best practices | # Copyright 2015-2022 the openage authors. See copying.md for legal info.
from concurrent.futures import ThreadPoolExecutor
from enum import Enum
import itertools
import os
from queue import Queue
def concurrent_chain(generators, jobs=None):
if jobs is None:
jobs = os.cpu_count()
if jobs == 1:
... | --- +++ @@ -1,5 +1,8 @@ # Copyright 2015-2022 the openage authors. See copying.md for legal info.
+"""
+Threading utilities.
+"""
from concurrent.futures import ThreadPoolExecutor
from enum import Enum
@@ -9,6 +12,14 @@
def concurrent_chain(generators, jobs=None):
+ """
+ Similar to itertools.chain(), b... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/threading.py |
Provide clean and structured docstrings | # Copyright 2015-2022 the openage authors. See copying.md for legal info.
from typing import Iterable
def denote_last(iterable: Iterable):
# pylint: disable=stop-iteration-return
iterator = iter(iterable)
current = next(iterator)
for future in iterator:
yield current, False
current... | --- +++ @@ -1,11 +1,18 @@ # Copyright 2015-2022 the openage authors. See copying.md for legal info.
+"""
+Provides all sorts of iterator-related stuff.
+"""
from typing import Iterable
def denote_last(iterable: Iterable):
+ """
+ Similar to enumerate, this iterates over an iterable, and yields
+ tu... | https://raw.githubusercontent.com/SFTtech/openage/HEAD/openage/util/iterators.py |
Write beginner-friendly docstrings | # -*- coding: utf-8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope... | --- +++ @@ -74,18 +74,34 @@
class ForceQuitHandler:
+ """Strategy for handling force quit on repeated Ctrl+C.
+
+ Different platforms have different signal handling behaviors. This base
+ class defines the interface, with subclasses implementing platform-specific
+ logic.
+ """
def check_force... | https://raw.githubusercontent.com/maurosoria/dirsearch/HEAD/lib/controller/controller.py |
Add docstrings including usage examples | # -*- coding: utf-8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope... | --- +++ @@ -83,6 +83,7 @@ yield scanner
def is_excluded(self, resp: BaseResponse) -> bool:
+ """Validate the response by different filters"""
if resp.status in options["exclude_status_codes"]:
return True
@@ -226,6 +227,10 @@ self._play_event.set()
def pa... | https://raw.githubusercontent.com/maurosoria/dirsearch/HEAD/lib/core/fuzzer.py |
Create docstrings for API functions | # -*- coding: utf-8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope... | --- +++ @@ -54,6 +54,9 @@ self.wildcard_redirect_regex = None
def check(self, path: str, response: BaseResponse) -> bool:
+ """
+ Perform analyzing to see if the response is wildcard or not
+ """
if self.response.status != response.status:
return True
@@ -92,6... | https://raw.githubusercontent.com/maurosoria/dirsearch/HEAD/lib/core/scanner.py |
Add well-formatted docstrings | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,20 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""YAPF.
+
+YAPF uses the algorithm in clang-format to figure out the "best" formatting for
+Python code. It loo... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/__init__.py |
Add docstrings explaining edge cases | # Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
# Python imports
import itertools
from . import pygram
from .fixer_util import does_tree_import
# Local imports
from .patcomp import PatternCompiler
class BaseFix(object):
PATTERN = None # Most subclasses should ... | --- +++ @@ -1,5 +1,6 @@ # Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
+"""Base class for fixers (optional, but recommended)."""
# Python imports
import itertools
@@ -11,6 +12,13 @@
class BaseFix(object):
+ """Optional base class for fixers.
+
+ The subcla... | https://raw.githubusercontent.com/google/yapf/HEAD/third_party/yapf_third_party/_ylib2to3/fixer_base.py |
Generate consistent documentation across files | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,16 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Calculate the number of blank lines between top-level entities.
+
+Calculates how many blank lines we need be... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/pytree/blank_line_calculator.py |
Generate docstrings for exported functions | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,13 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Insert "continuation" nodes into lib2to3 tree.
+
+The "backslash-newline" continuation marker is shoved into ... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/pytree/continuation_splicer.py |
Add docstrings to meet PEP guidelines | # Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
__author__ = 'Guido van Rossum <guido@python.org>'
# Python imports
import io
# Really local imports
from . import pygram
from . import pytree
# Fairly local imports
from .pgen2 import driver
from .pgen2 import gramma... | --- +++ @@ -1,5 +1,11 @@ # Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
+"""Pattern compiler.
+
+The grammar is taken from PatternGrammar.txt.
+
+The compiler compiles a pattern to a pytree.*Pattern instance.
+"""
__author__ = 'Guido van Rossum <guido@python.org>... | https://raw.githubusercontent.com/google/yapf/HEAD/third_party/yapf_third_party/_ylib2to3/patcomp.py |
Add docstrings for internal functions | # Author: Collin Winter
from . import patcomp
# Local imports
from .pgen2 import token
from .pygram import python_symbols as syms
from .pytree import Leaf
from .pytree import Node
###########################################################
# Common node-construction "macros"
##########################################... | --- +++ @@ -1,3 +1,4 @@+"""Utility functions, node construction macros, etc."""
# Author: Collin Winter
from . import patcomp
@@ -25,6 +26,7 @@
def Assign(target, source):
+ """Build an assignment statement"""
if not isinstance(target, list):
target = [target]
if not isinstance(source, list):
@@ -35... | https://raw.githubusercontent.com/google/yapf/HEAD/third_party/yapf_third_party/_ylib2to3/fixer_util.py |
Auto-generate documentation strings for this file | # Copyright 2022 Bill Wendling, All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | --- +++ @@ -11,6 +11,24 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Simple Python Parser
+
+Parse Python code into a list of logical lines, represented by LogicalLine
+objects. ... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/pyparser/pyparser.py |
Write docstrings for algorithm functions | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
# Python imports
import re
# Local imports
from pgen2 import grammar
from pgen2 import token
class Converter(grammar.Grammar):
def run(self, graminit_h, graminit_c):
self.parse_graminit_h(gram... | --- +++ @@ -1,5 +1,29 @@ # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
+"""Convert graminit.[ch] spit out by pgen to Python code.
+
+Pgen is the Python parser generator. It is useful to quickly create a
+parser from a grammar file in Python's gram... | https://raw.githubusercontent.com/google/yapf/HEAD/third_party/yapf_third_party/_ylib2to3/pgen2/conv.py |
Generate docstrings for each module | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,18 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Generic visitor pattern for pytrees.
+
+The lib2to3 parser produces a "pytree" - syntax tree consisting of No... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/pytree/pytree_visitor.py |
Generate documentation strings for clarity | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Computation of split penalties before/between tokens."""
import re
@@ -51,10 +52,19 @@
def ComputeSpl... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/pytree/split_penalty.py |
Write docstrings for this repository | # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation.
# All rights reserved.
__author__ = 'Ka-Ping Yee <ping@lfw.org>'
__credits__ = \
'GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaro'
import re
import string
from codecs import BOM_UTF8
from codecs import lookup
from . i... | --- +++ @@ -1,5 +1,28 @@ # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation.
# All rights reserved.
+"""Tokenization help for Python programs.
+
+generate_tokens(readline) is a generator that breaks a stream of
+text into Python tokens. It accepts a readline-like method which is called
+rep... | https://raw.githubusercontent.com/google/yapf/HEAD/third_party/yapf_third_party/_ylib2to3/pgen2/tokenize.py |
Add docstrings following best practices | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
# Modifications:
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
__author__ = 'Guido van Rossum <guido@python.org>'
__all__ = ['Driver', 'load_gramm... | --- +++ @@ -4,6 +4,11 @@ # Modifications:
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
+"""Parser driver.
+
+This provides a high-level interface to parse a file into a syntax tree.
+
+"""
__author__ = 'Guido van Rossum <guido@python.org>'
@@ -115,6 +120,7 @... | https://raw.githubusercontent.com/google/yapf/HEAD/third_party/yapf_third_party/_ylib2to3/pgen2/driver.py |
Add documentation for all methods | # Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
# Python imports
import os
# Local imports
from .pgen2 import driver
# The grammar file
_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), 'Grammar.txt')
_PATTERN_GRAMMAR_FILE = os.path.join(
os.path.dirname(... | --- +++ @@ -1,5 +1,6 @@ # Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
+"""Export the Python grammar and symbols."""
# Python imports
import os
@@ -16,6 +17,11 @@ class Symbols(object):
def __init__(self, grammar):
+ """Initializer.
+
+ Creates an... | https://raw.githubusercontent.com/google/yapf/HEAD/third_party/yapf_third_party/_ylib2to3/pygram.py |
Please document this code using docstrings | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,28 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Join logical lines together.
+
+Determine how many lines can be joined into one line. For instance, we could
... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/yapflib/line_joiner.py |
Document my Python code with docstrings | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
from contextlib import contextmanager
from typing import Any
from typing import Callable
from typing import Dict
from typing import Iterator
from typing import List
from typing import Optional
from typin... | --- +++ @@ -1,5 +1,13 @@ # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
+"""Parser engine for the grammar tables generated by pgen.
+
+The grammar table must be loaded first.
+
+See Parser/parser.c in the Python distribution for additional info on
+... | https://raw.githubusercontent.com/google/yapf/HEAD/third_party/yapf_third_party/_ylib2to3/pgen2/parse.py |
Generate descriptive docstrings automatically | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Enhanced token information for formatting."""
import keyword
import re
@@ -30,6 +31,16 @@
def _TabbedC... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/yapflib/format_token.py |
Generate missing documentation strings | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
# Python imports
import os
import pickle
import tempfile
# Local imports
from . import token
class Grammar(object):
def __init__(self):
self.symbol2number = {}
self.number2symbol = {}
... | --- +++ @@ -1,5 +1,15 @@ # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
+"""This module defines the data structures used to represent a grammar.
+
+These are a bit arcane because they are derived from the data
+structures used by Python's 'pgen' par... | https://raw.githubusercontent.com/google/yapf/HEAD/third_party/yapf_third_party/_ylib2to3/pgen2/grammar.py |
Add docstrings explaining edge cases | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,18 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""pytree-related utilities.
+
+This module collects various utilities related to the parse trees produced by
+t... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/pytree/pytree_utils.py |
Write docstrings for utility functions | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,13 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Decide what the format for the code should be.
+
+The `logical_line.LogicalLine`s are now ready to be formatt... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/yapflib/reformatter.py |
Add docstrings including usage examples | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,18 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Subtype assigner for format tokens.
+
+This module assigns extra type information to format tokens. This info... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/pytree/subtype_assigner.py |
Help me comply with documentation standards | # Copyright 2022 Bill Wendling, All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | --- +++ @@ -11,9 +11,26 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""PyParser-related utilities.
+
+This module collects various utilities related to the parse trees produced by
... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/pyparser/pyparser_utils.py |
Create documentation for each function signature | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,20 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Implements a format decision state object that manages whitespace decisions.
+
+Each token is processed one a... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/yapflib/format_decision_state.py |
Help me add docstrings to my project | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,20 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""PyTreeUnwrapper - produces a list of logical lines from a pytree.
+
+[for a description of what a logical lin... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/pytree/pytree_unwrapper.py |
Add return value explanations in docstrings | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Python formatting style settings."""
import os
import re
@@ -27,22 +28,27 @@
class StyleConfigError(er... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/yapflib/style.py |
Add docstrings for better understanding | # Copyright 2018 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,13 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Identify containers for lib2to3 trees.
+
+This module identifies containers and the elements in them. Each el... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/yapflib/identify_container.py |
Can you add docstrings to this Python file? | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Interface to file resources.
+
+This module provides functions for interfacing with files: opening, writing, ... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/yapflib/file_resources.py |
Create documentation for each function signature | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,25 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Entry points for YAPF.
+
+The main APIs that YAPF exposes to drive the reformatting.
+
+ FormatFile(): refor... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/yapflib/yapf_api.py |
Add docstrings to clarify complex logic | # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,11 +11,24 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""YAPF error objects."""
from yapf_third_party._ylib2to3.pgen2 import tokenize
def FormatErrorMsg(e):
... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/yapflib/errors.py |
Provide clean and structured docstrings | import textwrap, logging
from explainshell import util
class basefixer(object):
runbefore = []
runlast = False
def __init__(self, mctx):
self.mctx = mctx
self.run = True
self.logger = logging.getLogger(self.__class__.__name__)
def pre_get_raw_manpage(self):
pass
... | --- +++ @@ -3,6 +3,10 @@ from explainshell import util
class basefixer(object):
+ '''The base fixer class which other fixers inherit from.
+
+ Subclasses override the base methods in order to fix manpage content during
+ different parts of the parsing/classifying/saving process.'''
runbefore = []
... | https://raw.githubusercontent.com/idank/explainshell/HEAD/explainshell/fixer.py |
Create documentation for each function signature | # Copyright 2017 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | --- +++ @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Represents the state of Python objects being formatted.
+
+Objects (e.g., list comprehensions, dictionaries, ... | https://raw.githubusercontent.com/google/yapf/HEAD/yapf/yapflib/object_state.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.