Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pysteam/_crc_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def bit_by_bit(self, in_data):
value at the end.
"""
# If the input data is a string, convert to bytes.
if isinstance(in_data, str):
if isinstance(in_data, str) or isinstance(in_data, unicode):
in_data = [ord(c) for c in in_data]

register = self.NonDirectInit
Expand Down Expand Up @@ -165,7 +165,7 @@ def bit_by_bit_fast(self, in_data):
wich are appended to the input message in the bit-by-bit algorithm.
"""
# If the input data is a string, convert to bytes.
if isinstance(in_data, str):
if isinstance(in_data, str) or isinstance(in_data, unicode):
in_data = [ord(c) for c in in_data]

register = self.DirectInit
Expand Down Expand Up @@ -219,7 +219,7 @@ def table_driven(self, in_data):
The Standard table_driven CRC algorithm.
"""
# If the input data is a string, convert to bytes.
if isinstance(in_data, str):
if isinstance(in_data, str) or isinstance(in_data, unicode):
in_data = [ord(c) for c in in_data]

tbl = self.gen_table()
Expand Down
3 changes: 2 additions & 1 deletion pysteam/_shortcut_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def to_string(self,shortcuts):
string = x00 + 'shortcuts' + x00 + self.generate_array_string(shortcuts) + x08 + x08 + x0a
# rstrip is to remove the eol character that is automatically added.
# According to vim the files I got from steam don't have the eol character
return unicode(string).rstrip()
try: return unicode(string).rstrip()
except NameError: return string.rstrip()

def generate_array_string(self,shortcuts):
string = ""
Expand Down
10 changes: 5 additions & 5 deletions pysteam/_shortcut_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os
import re

import shortcut
from pysteam import shortcut

class ShortcutParser(object):

Expand All @@ -22,7 +22,7 @@ def parse(self, path):
return self.match_base(file_contents)

def match_base(self,string):
match = re.match(ur"\u0000shortcuts\u0000(.*)\u0008\u0008$",string, re.IGNORECASE)
match = re.match(u"\u0000shortcuts\u0000(.*)\u0008\u0008$",string, re.IGNORECASE)
if match:
return self.match_array_string(match.groups()[0])
else:
Expand All @@ -37,7 +37,7 @@ def match_array_string(self,string):
# ignoring it for now
shortcuts = []
while True:
match = re.match(ur"(.*)\u0000[0-9]+\u0000(\u0001AppName.*)\u0008",string, re.IGNORECASE)
match = re.match(u"(.*)\u0000[0-9]+\u0000(\u0001AppName.*)\u0008",string, re.IGNORECASE)
if match:
groups = match.groups()
string = groups[0]
Expand All @@ -51,7 +51,7 @@ def match_shortcut_string(self,string):
# for the shortcut string (Appname, Exe, StartDir, etc), as oppposed
# to matching for general Key-Value pairs. This could possibly create a
# lot of work for me later, but for now it will get the job done
match = re.match(ur"\u0001AppName\u0000(.*)\u0000\u0001Exe\u0000(.*)\u0000\u0001StartDir\u0000(.*)\u0000\u0001icon\u0000(.*)\u0000\u0000tags\u0000(.*)\u0008",string, re.IGNORECASE)
match = re.match(u"\u0001AppName\u0000(.*)\u0000\u0001Exe\u0000(.*)\u0000\u0001StartDir\u0000(.*)\u0000\u0001icon\u0000(.*)\u0000\u0000tags\u0000(.*)\u0008",string, re.IGNORECASE)
if match:
# The 'groups' that are returned by the match should be the data
# contained in the file. Now just make a Shortcut out of that data
Expand All @@ -68,7 +68,7 @@ def match_shortcut_string(self,string):
def match_tags_string(self,string):
tags = []
while True:
match = re.match(ur"(.*)\u0001[0-9]+\u0000(.*?)\u0000",string)
match = re.match(u"(.*)\u0001[0-9]+\u0000(.*?)\u0000",string)
if match:
groups = match.groups()
string = groups[0]
Expand Down
11 changes: 9 additions & 2 deletions pysteam/shortcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import sys
import os

import game
from _crc_algorithms import Crc
from pysteam import game
from pysteam._crc_algorithms import Crc

class Shortcut(game.Game):

Expand All @@ -24,6 +24,13 @@ def __init__(self, name, exe, startdir, icon="", tags=None):
self.icon = icon
self.tags = tags

def __eq__(self, other):
return (self.name == other.name and
self.exe == other.exe and
self.startdir == other.startdir and
self.icon == other.icon and
self.tags == other.tags)

def appid(self):
algorithm = Crc(width = 32, poly = 0x04C11DB7, reflect_in = True, xor_in = 0xffffffff, reflect_out = True, xor_out = 0xffffffff)
crc_input = ''.join([self.exe,self.name])
Expand Down
7 changes: 4 additions & 3 deletions pysteam/steam.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import sys
import os

import user
from pysteam import user

def _is_mac():
return sys.platform == 'darwin'
Expand All @@ -26,7 +26,8 @@ def _is_linux():
def _windows_steam_location():
if not _is_windows():
return
import _winreg as registry
try: import _winreg as registry
except: import winreg as registry
key = registry.CreateKey(registry.HKEY_CURRENT_USER,"Software\Valve\Steam")
return registry.QueryValueEx(key,"SteamPath")[0]

Expand Down Expand Up @@ -85,4 +86,4 @@ def local_users(self):
# machine is to just list the folders inside userdata
userdirs = filter(self._is_user_directory, os.listdir(self.userdata_location()))
# Exploits the fact that the directory is named the same as the user id
return map(lambda userdir: user.User(self, int(userdir)), userdirs)
return list(map(lambda userdir: user.User(self, int(userdir)), userdirs))
7 changes: 4 additions & 3 deletions pysteam/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
Copyright (c) 2013 Scott Rice. All rights reserved.
"""

from __future__ import print_function
import sys
import os

from _shortcut_parser import ShortcutParser
from _shortcut_generator import ShortcutGenerator
from pysteam._shortcut_parser import ShortcutParser
from pysteam._shortcut_generator import ShortcutGenerator

# Information about SteamIDs and conversion between them found here:
# https://developer.valvesoftware.com/wiki/SteamID
Expand Down Expand Up @@ -66,7 +67,7 @@ def _load_shortcuts(self):
parsed_shortcuts = []
if parsed_shortcuts == None:
# TODO: Raise a decent error
print "Parsing error on file: %s" % file
print("Parsing error on file: %s" % file)
parsed_shortcuts = []
return parsed_shortcuts

Expand Down