Skip to content

Commit

Permalink
Scanner reads session, guitars
Browse files Browse the repository at this point in the history
  • Loading branch information
BuongiornoTexas committed May 27, 2019
1 parent b3fa81c commit a7c81a5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion rsrtools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Tools for creating Rocksmith 2014 songlists and managing Rocksmith save files."""

__version__ = '0.3.0'
__version__ = '0.3.1'
44 changes: 34 additions & 10 deletions rsrtools/songlists/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ class Scanner:

# Rocksmith install path
_rs_path: Path
# The file being scanned by _arrangement_rows
_current_psarc: Path

def __init__(self) -> None:
"""Get the Rocksmith directory for scanner iterator."""
Expand Down Expand Up @@ -283,17 +285,28 @@ def _internal_data(self, data: bytes, last_modified: float) -> Dict[str, Any]:
for arr_id in sub_dict.keys():
pass

sub_dict = sub_dict[arr_id]["Attributes"]

if arr_id != sub_dict["PersistentID"]:
raise ValueError("Inconsistent persistent id data in Arrangement file.")
arrangement[ListField.ARRANGEMENT_ID.value] = arr_id

# Provide something modestly useful in case anyone goes digging.
try:
arrangement[ListField.SONG_KEY.value] = sub_dict["SongKey"]
except KeyError:
arrangement[ListField.SONG_KEY.value] = sub_dict["LessonKey"]
# Provide something modestly useful in song key, title in case anyone goes
# digging. Cross check arr_id.
if json["InsertRoot"].startswith("Static.SessionMode"):
# Session mode entries don't have a persistent ID, so can't cross check.
arrangement[ListField.SONG_KEY.value] = "Session Mode Entry"

else:
sub_dict = sub_dict[arr_id]["Attributes"]

if arr_id != sub_dict["PersistentID"]:
raise ValueError("Inconsistent persistent id data in Arrangement file.")

if json["InsertRoot"].startswith("Static.Guitars"):
arrangement[ListField.SONG_KEY.value] = "Guitar Entry"
else:
try:
arrangement[ListField.SONG_KEY.value] = sub_dict["SongKey"]
except KeyError:
arrangement[ListField.SONG_KEY.value] = sub_dict["LessonKey"]

arrangement[ListField.TITLE.value] = arrangement[ListField.SONG_KEY.value]

# Dummy entries from here - the goal is just to know if RS is
Expand Down Expand Up @@ -401,6 +414,7 @@ def _arrangement_rows(
Iterator[Dict[str, Any]] -- Iterator of arrangement values - see db_entries.
"""
self._current_psarc = psarc_path
last_modified = psarc_path.stat().st_mtime
with Welder(psarc_path, "r") as psarc:
for index in psarc:
Expand Down Expand Up @@ -490,13 +504,23 @@ def db_entries(
):
yield arrangement

# Finally, scan etudes
# Finally, scan etudes, guitars, session mode.
if scan_all:
for arrangement in self._arrangement_rows(
self._rs_path.joinpath("etudes.psarc"), True
):
yield arrangement

for arrangement in self._arrangement_rows(
self._rs_path.joinpath("guitars.psarc"), True
):
yield arrangement

for arrangement in self._arrangement_rows(
self._rs_path.joinpath("session.psarc"), True
):
yield arrangement


if __name__ == "__main__":
pass

0 comments on commit a7c81a5

Please sign in to comment.