prompt
large_stringlengths 72
9.34k
| completion
large_stringlengths 0
7.61k
|
---|---|
<|file_name|>setup_pkgresource.py<|end_file_name|><|fim▁begin|>def _setup_pkgresources():
import pkg_resources
import os
import plistlib
pl = plistlib.readPlist(os.path.join(
os.path.dirname(os.getenv('RESOURCEPATH')), "Info.plist"))
appname = pl.get('CFBundleIdentifier')
if appname is None:
<|fim_middle|>
path = os.path.expanduser('~/Library/Caches/%s/python-eggs' % (appname,))
pkg_resources.set_extraction_path(path)
_setup_pkgresources()
<|fim▁end|> | appname = pl['CFBundleDisplayName'] |
<|file_name|>setup_pkgresource.py<|end_file_name|><|fim▁begin|>def <|fim_middle|>():
import pkg_resources
import os
import plistlib
pl = plistlib.readPlist(os.path.join(
os.path.dirname(os.getenv('RESOURCEPATH')), "Info.plist"))
appname = pl.get('CFBundleIdentifier')
if appname is None:
appname = pl['CFBundleDisplayName']
path = os.path.expanduser('~/Library/Caches/%s/python-eggs' % (appname,))
pkg_resources.set_extraction_path(path)
_setup_pkgresources()
<|fim▁end|> | _setup_pkgresources |
<|file_name|>output2csv.py<|end_file_name|><|fim▁begin|>import os, re, csv
# regular expressions for capturing the interesting quantities
noise_pattern = 'noise: \[(.+)\]'
res_pattern = '^([0-9.]+$)'
search_dir = "output"
results_file = '../results.csv'
os.chdir( search_dir )
files = filter( os.path.isfile, os.listdir( '.' ))
#files = [ os.path.join( search_dir, f ) for f in files ] # add path to each file
files.sort( key=lambda x: os.path.getmtime( x ))
results = []
for file in files:
f = open( file )
contents = f.read()
# noise
matches = re.search( noise_pattern, contents, re.DOTALL )
try:
noise = matches.group( 1 )
noise = noise.strip()
noise = noise.split()
except AttributeError:<|fim▁hole|> print "noise error 1: %s" % ( contents )
continue
# rmse
matches = re.search( res_pattern, contents, re.M )
try:
res = matches.group( 1 )
except AttributeError:
print "matches error 2: %s" % ( contents )
continue
results.append( [ res ] + noise )
writer = csv.writer( open( results_file, 'wb' ))
for result in results:
writer.writerow( result )<|fim▁end|> | |
<|file_name|>extensions.py<|end_file_name|><|fim▁begin|>#
# 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 agreed to in writing, software<|fim▁hole|># WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from solum.api.controllers import common_types
from solum.api.controllers.v1.datamodel import types as api_types
#from solum.openstack.common import log as logging
#LOG = logging.getLogger(__name__)
class Extensions(api_types.Base):
"""extensions resource"""
extension_links = [common_types.Link]
"""This attribute contains Links to extension resources that contain
information about the extensions supported by this Platform."""
def __init__(self, **kwds):
# LOG.debug("extensions constructor: %s" % kwds)
super(Extensions, self).__init__(**kwds)<|fim▁end|> | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
<|file_name|>extensions.py<|end_file_name|><|fim▁begin|>#
# 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 agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, 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.
from solum.api.controllers import common_types
from solum.api.controllers.v1.datamodel import types as api_types
#from solum.openstack.common import log as logging
#LOG = logging.getLogger(__name__)
class Extensions(api_types.Base):
<|fim_middle|>
<|fim▁end|> | """extensions resource"""
extension_links = [common_types.Link]
"""This attribute contains Links to extension resources that contain
information about the extensions supported by this Platform."""
def __init__(self, **kwds):
# LOG.debug("extensions constructor: %s" % kwds)
super(Extensions, self).__init__(**kwds) |
<|file_name|>extensions.py<|end_file_name|><|fim▁begin|>#
# 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 agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, 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.
from solum.api.controllers import common_types
from solum.api.controllers.v1.datamodel import types as api_types
#from solum.openstack.common import log as logging
#LOG = logging.getLogger(__name__)
class Extensions(api_types.Base):
"""extensions resource"""
extension_links = [common_types.Link]
"""This attribute contains Links to extension resources that contain
information about the extensions supported by this Platform."""
def __init__(self, **kwds):
# LOG.debug("extensions constructor: %s" % kwds)
<|fim_middle|>
<|fim▁end|> | super(Extensions, self).__init__(**kwds) |
<|file_name|>extensions.py<|end_file_name|><|fim▁begin|>#
# 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 agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, 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.
from solum.api.controllers import common_types
from solum.api.controllers.v1.datamodel import types as api_types
#from solum.openstack.common import log as logging
#LOG = logging.getLogger(__name__)
class Extensions(api_types.Base):
"""extensions resource"""
extension_links = [common_types.Link]
"""This attribute contains Links to extension resources that contain
information about the extensions supported by this Platform."""
def <|fim_middle|>(self, **kwds):
# LOG.debug("extensions constructor: %s" % kwds)
super(Extensions, self).__init__(**kwds)
<|fim▁end|> | __init__ |
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI<|fim▁hole|> ## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList<|fim▁end|> | #GUI.dlgOk(str( jsp.count ))
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if<|fim_middle|>
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
fo<|fim_middle|>
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | r itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_i<|fim_middle|>
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | tmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if<|fim_middle|>
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
de<|fim_middle|>
<|fim▁end|> | f __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if<|fim_middle|>
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
js<|fim_middle|>
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | p = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
se<|fim_middle|>
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | lf.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
se<|fim_middle|>
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | lf.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
se<|fim_middle|>
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | lf.vidListItems.reverse()
self.vidListItemsRaw.reverse()
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
ne<|fim_middle|>
<|fim▁end|> | xts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def is<|fim_middle|>idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | Folder ( |
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def is<|fim_middle|>ame):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | VidExt(n |
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def ge<|fim_middle|>irPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | tJsp(d |
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def js<|fim_middle|>sp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | p_isFolder(j |
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __<|fim_middle|>elf, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | init__(s |
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def js<|fim_middle|>elf, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | p_init(s |
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def no<|fim_middle|>elf):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | rm_init(s |
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def se<|fim_middle|>elf, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | tmanually(s |
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def re<|fim_middle|>elf):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | verse(s |
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def ge<|fim_middle|>elf):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | tOnlyNexts(s |
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : re <|fim_middle|>
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | turn False
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : re <|fim_middle|>
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | turn True
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : re <|fim_middle|>
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | turn False
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : se <|fim_middle|>
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | lf.norm_init()
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : se <|fim_middle|>
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | lf.jsp_init (dirPath, srcName)
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : co <|fim_middle|>
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | ntinue
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
se <|fim_middle|>
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | lf.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : se <|fim_middle|>
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | lf.vidFolderNameDef = self.vidCurr
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : co <|fim_middle|>
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | ntinue
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
se <|fim_middle|>
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | lf.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : se <|fim_middle|>
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | lf.vidFolderNameDef = self.vidListItems[0][0]
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : ne <|fim_middle|>
if not nexts : continue
retList.append(itm[1])
return retList
<|fim▁end|> | xts = True; continue
|
<|file_name|>li2_.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Taifxx
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########## LI2 (JSP):
### Import modules ...
from base import *
DETVIDEXT = False
### Items ...
currentItemPos = lambda : inte(xbmc.getInfoLabel('Container.CurrentItem'))
itemsCount = lambda : inte(xbmc.getInfoLabel('Container.NumItems'))
### Container info ...
getCpath = lambda : xbmc.getInfoLabel('Container.FolderPath')
getCname = lambda : xbmc.getInfoLabel('Container.FolderName')
getCplug = lambda : xbmc.getInfoLabel('Container.PluginName')
### Listitem info ...
getLi = lambda infolabel, idx=currentItemPos() : xbmc.getInfoLabel('ListitemNoWrap(%s).%s' % (str(idx-currentItemPos()), infolabel))
getIcn = lambda idx=currentItemPos() : getLi('Icon', idx)
getTbn = lambda idx=currentItemPos() : getLi('Thumb', idx)
getLink = lambda idx=currentItemPos() : getLi('FileNameAndPath', idx)
getPath = lambda idx=currentItemPos() : getLi('Path', idx)
getFname = lambda idx=currentItemPos() : getLi('FileName', idx)
getFolpath = lambda idx=currentItemPos() : getLi('FolderPath', idx)
getTitle = lambda idx=currentItemPos() : getLi('Label', idx)
getTitleF = lambda idx=currentItemPos() : getLi('Label', idx)
# def getTitleF (idx=currentItemPos()):
# tmpTitle = getTitle(idx)
# tmpFname = getFname(idx)
# return tmpFname if tmpFname else tmpTitle
def isFolder (idx=currentItemPos()):
if DETVIDEXT and isVidExt(getTitle(idx)) : return False
return True if getLi('Property(IsPlayable)',idx) in ('false', Empty) and not getFname(idx) else False
def isVidExt(name):
for itm in TAG_PAR_VIDEOSEXT:
if name.endswith(itm) : return True
return False
### JSP functions ...
_listdircmd = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"properties": ["file", "title"], "directory":"%s", "media":"files"}, "id": "1"}'
def getJsp(dirPath, srcName):
_itmList = eval(xbmc.executeJSONRPC(_listdircmd % (dirPath)))['result']['files']
_jsp = struct()
_jsp.link = dirPath
_jsp.name = srcName
_jsp.itmList = _itmList
_jsp.count = len(_itmList)
return _jsp
jsp_getLabel = lambda jsp, idx=0 : jsp.itmList[idx]['label']
jsp_getLink = lambda jsp, idx=0 : jsp.itmList[idx]['file']
def jsp_isFolder(jsp, idx):
if jsp.itmList[idx]['filetype'] != 'folder' : return False
return True
### Listitems Object ...
class vidItems:
def __init__(self, dirPath=Empty, srcName=Empty):
if not dirPath : self.norm_init()
else : self.jsp_init (dirPath, srcName)
def jsp_init(self, dirPath, srcName):
jsp = getJsp(dirPath, srcName)
#import resources.lib.gui as GUI
#GUI.dlgOk(str( jsp.count ))
## Current jsp data ...
self.vidFolderNameDef = Empty
self.vidCPath = jsp.link
self.vidCName = jsp.name
self.vidIsEmpty = True
self.vidFolCount = jsp.count
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## Create items list ...
for idx in range(0, self.vidFolCount):
self.vidListItemsRaw.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if jsp_isFolder(jsp, idx) : continue
self.vidListItems.append([jsp_getLabel(jsp, idx), jsp_getLink(jsp, idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item ...
self.vidFolderNameDef = self.vidListItems[0][0]
def norm_init(self):
## Current listitem data ...
self.vidFolderNameDef = Empty
self.vidCurr = getTitleF()
self.vidPath = getPath()
self.vidIsFolder = isFolder()
self.vidFPath = getFolpath()
self.vidLink = getLink()
self.vidCPath = getCpath()
self.vidCName = getCname()
self.vidCPlug = getCplug()
self.vidIsEmpty = True
self.vidFolCount = itemsCount()
## Local items list...
self.vidListItems = []
self.vidListItemsRaw = []
## If current item is not a folder, set it as default ...
if not self.vidIsFolder : self.vidFolderNameDef = self.vidCurr
## Create items list ...
for idx in range(1, self.vidFolCount+1):
self.vidListItemsRaw.append([getTitleF(idx), getLink(idx)])
if isFolder(idx) : continue
self.vidListItems.append([getTitleF(idx), getLink(idx)])
if self.vidListItems :
self.vidIsEmpty = False
## Set as default first nofolder item, if current item is a folder ...
if self.vidFolderNameDef == Empty : self.vidFolderNameDef = self.vidListItems[0][0]
def setmanually(self, manlist):
self.vidListItems = [itm for idx, itm in enumerate(self.vidListItemsRaw) if idx in manlist]
def reverse(self):
self.vidListItems.reverse()
self.vidListItemsRaw.reverse()
def getOnlyNexts(self):
nexts = False
retList = []
for itm in self.vidListItems:
if itm[0] == self.vidCurr : nexts = True; continue
if not nexts : co <|fim_middle|>
retList.append(itm[1])
return retList
<|fim▁end|> | ntinue
|
<|file_name|>test_DelEntry.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
'''
##BOILERPLATE_COPYRIGHT
##BOILERPLATE_COPYRIGHT_END
'''
import unittest, copy
from testRoot import RootClass
from noink.user_db import UserDB
from noink.entry_db import EntryDB
class AddEntry(RootClass):
def test_AddEntry(self):
userDB = UserDB()
entryDB = EntryDB()
u = userDB.add("jontest", "pass", "Jon Q. Testuser")<|fim▁hole|> "Wait... how'd she fit in that bucket anyway?"
e = entryDB.add(copy.deepcopy(title), entry, u)
self.assertTrue(e.title == title)
if __name__ == '__main__':
unittest.main()<|fim▁end|> | title = 'Little Buttercup'
entry = 'There once was a man from Nantucket,' + \
'who kept his wife in a Bucket.' + \ |
<|file_name|>test_DelEntry.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
'''
##BOILERPLATE_COPYRIGHT
##BOILERPLATE_COPYRIGHT_END
'''
import unittest, copy
from testRoot import RootClass
from noink.user_db import UserDB
from noink.entry_db import EntryDB
class AddEntry(RootClass):
<|fim_middle|>
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | def test_AddEntry(self):
userDB = UserDB()
entryDB = EntryDB()
u = userDB.add("jontest", "pass", "Jon Q. Testuser")
title = 'Little Buttercup'
entry = 'There once was a man from Nantucket,' + \
'who kept his wife in a Bucket.' + \
"Wait... how'd she fit in that bucket anyway?"
e = entryDB.add(copy.deepcopy(title), entry, u)
self.assertTrue(e.title == title) |
<|file_name|>test_DelEntry.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
'''
##BOILERPLATE_COPYRIGHT
##BOILERPLATE_COPYRIGHT_END
'''
import unittest, copy
from testRoot import RootClass
from noink.user_db import UserDB
from noink.entry_db import EntryDB
class AddEntry(RootClass):
def test_AddEntry(self):
<|fim_middle|>
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | userDB = UserDB()
entryDB = EntryDB()
u = userDB.add("jontest", "pass", "Jon Q. Testuser")
title = 'Little Buttercup'
entry = 'There once was a man from Nantucket,' + \
'who kept his wife in a Bucket.' + \
"Wait... how'd she fit in that bucket anyway?"
e = entryDB.add(copy.deepcopy(title), entry, u)
self.assertTrue(e.title == title) |
<|file_name|>test_DelEntry.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
'''
##BOILERPLATE_COPYRIGHT
##BOILERPLATE_COPYRIGHT_END
'''
import unittest, copy
from testRoot import RootClass
from noink.user_db import UserDB
from noink.entry_db import EntryDB
class AddEntry(RootClass):
def test_AddEntry(self):
userDB = UserDB()
entryDB = EntryDB()
u = userDB.add("jontest", "pass", "Jon Q. Testuser")
title = 'Little Buttercup'
entry = 'There once was a man from Nantucket,' + \
'who kept his wife in a Bucket.' + \
"Wait... how'd she fit in that bucket anyway?"
e = entryDB.add(copy.deepcopy(title), entry, u)
self.assertTrue(e.title == title)
if __name__ == '__main__':
<|fim_middle|>
<|fim▁end|> | unittest.main() |
<|file_name|>test_DelEntry.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
'''
##BOILERPLATE_COPYRIGHT
##BOILERPLATE_COPYRIGHT_END
'''
import unittest, copy
from testRoot import RootClass
from noink.user_db import UserDB
from noink.entry_db import EntryDB
class AddEntry(RootClass):
def <|fim_middle|>(self):
userDB = UserDB()
entryDB = EntryDB()
u = userDB.add("jontest", "pass", "Jon Q. Testuser")
title = 'Little Buttercup'
entry = 'There once was a man from Nantucket,' + \
'who kept his wife in a Bucket.' + \
"Wait... how'd she fit in that bucket anyway?"
e = entryDB.add(copy.deepcopy(title), entry, u)
self.assertTrue(e.title == title)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | test_AddEntry |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals
from .atomicparsley import AtomicParsleyPP
from .ffmpeg import (
FFmpegPostProcessor,
FFmpegAudioFixPP,
FFmpegEmbedSubtitlePP,
FFmpegExtractAudioPP,
FFmpegFixupStretchedPP,
FFmpegMergerPP,
FFmpegMetadataPP,
FFmpegVideoConvertorPP,
)
from .xattrpp import XAttrMetadataPP
from .execafterdownload import ExecAfterDownloadPP
def get_postprocessor(key):
return globals()[key + 'PP']
__all__ = [
'AtomicParsleyPP',
'ExecAfterDownloadPP',
'FFmpegAudioFixPP',
'FFmpegEmbedSubtitlePP',
'FFmpegExtractAudioPP',
'FFmpegFixupStretchedPP',
'FFmpegMergerPP',<|fim▁hole|>]<|fim▁end|> | 'FFmpegMetadataPP',
'FFmpegPostProcessor',
'FFmpegVideoConvertorPP',
'XAttrMetadataPP', |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals
from .atomicparsley import AtomicParsleyPP
from .ffmpeg import (
FFmpegPostProcessor,
FFmpegAudioFixPP,
FFmpegEmbedSubtitlePP,
FFmpegExtractAudioPP,
FFmpegFixupStretchedPP,
FFmpegMergerPP,
FFmpegMetadataPP,
FFmpegVideoConvertorPP,
)
from .xattrpp import XAttrMetadataPP
from .execafterdownload import ExecAfterDownloadPP
def get_postprocessor(key):
<|fim_middle|>
__all__ = [
'AtomicParsleyPP',
'ExecAfterDownloadPP',
'FFmpegAudioFixPP',
'FFmpegEmbedSubtitlePP',
'FFmpegExtractAudioPP',
'FFmpegFixupStretchedPP',
'FFmpegMergerPP',
'FFmpegMetadataPP',
'FFmpegPostProcessor',
'FFmpegVideoConvertorPP',
'XAttrMetadataPP',
]
<|fim▁end|> | return globals()[key + 'PP'] |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals
from .atomicparsley import AtomicParsleyPP
from .ffmpeg import (
FFmpegPostProcessor,
FFmpegAudioFixPP,
FFmpegEmbedSubtitlePP,
FFmpegExtractAudioPP,
FFmpegFixupStretchedPP,
FFmpegMergerPP,
FFmpegMetadataPP,
FFmpegVideoConvertorPP,
)
from .xattrpp import XAttrMetadataPP
from .execafterdownload import ExecAfterDownloadPP
def <|fim_middle|>(key):
return globals()[key + 'PP']
__all__ = [
'AtomicParsleyPP',
'ExecAfterDownloadPP',
'FFmpegAudioFixPP',
'FFmpegEmbedSubtitlePP',
'FFmpegExtractAudioPP',
'FFmpegFixupStretchedPP',
'FFmpegMergerPP',
'FFmpegMetadataPP',
'FFmpegPostProcessor',
'FFmpegVideoConvertorPP',
'XAttrMetadataPP',
]
<|fim▁end|> | get_postprocessor |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
<|fim▁hole|> # applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()<|fim▁end|> | # The output streams a, b, c, d obtained by |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
<|fim_middle|>
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb]) |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): <|fim_middle|>
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | return [w*w for w in lst] |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
<|fim_middle|>
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | return w > threshold |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
<|fim_middle|>
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | return filter(predicate, lst) |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
<|fim_middle|>
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | return w**n |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
<|fim_middle|>
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | return map(power, lst) |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
<|fim_middle|>
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): <|fim_middle|>
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | return op(f,x) |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): <|fim_middle|>
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | return op(g,x) |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
<|fim_middle|>
if __name__ == '__main__':
main()
<|fim▁end|> | example_1() |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
<|fim_middle|>
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) ) |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
<|fim_middle|>
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) ) |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: <|fim_middle|>
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | result.append(w/n) |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
<|fim_middle|>
<|fim▁end|> | main() |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def <|fim_middle|>():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | example_1 |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def <|fim_middle|>(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | f |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def <|fim_middle|>(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | predicate |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def <|fim_middle|>(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | g |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def <|fim_middle|>(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | power |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def <|fim_middle|>(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | h |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def <|fim_middle|>(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | r |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def <|fim_middle|>(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | F |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def <|fim_middle|>(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def main():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | G |
<|file_name|>ExamplesOpNoState.py<|end_file_name|><|fim▁begin|>"""This module contains examples of the op() function
where:
op(f,x) returns a stream where x is a stream, and f
is an operator on lists, i.e., f is a function from
a list to a list. These lists are of lists of arbitrary
objects other than streams and agents.
Function f must be stateless, i.e., for any lists u, v:
f(u.extend(v)) = f(u).extend(f(v))
(Stateful functions are given in OpStateful.py with
examples in ExamplesOpWithState.py.)
Let f be a stateless operator on lists and let x be a stream.
If at some point, the value of stream x is a list u then at
that point, the value of stream op(f,x) is the list f(u).
If at a later point, the value of stream x is the list:
u.extend(v) then, at that point the value of stream op(f,x)
is f(u).extend(f(v)).
As a specific example, consider the following f():
def f(lst): return [w * w for w in lst]
If at some point in time, the value of x is [3, 7],
then at that point the value of op(f,x) is f([3, 7])
or [9, 49]. If at a later point, the value of x is
[3, 7, 0, 11, 5] then the value of op(f,x) at that point
is f([3, 7, 0, 11, 5]) or [9, 49, 0, 121, 25].
"""
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from Agent import *
from ListOperators import *
from PrintFunctions import print_streams_recent
def example_1():
print "example_1"
print "op(f, x): f is a function from a list to a list"
print "x is a stream \n"
# FUNCTIONS FROM LIST TO LIST
# This example uses the following list operators:
# functions from a list to a list.
# f, g, h, r
# Example A: function using list comprehension
def f(lst): return [w*w for w in lst]
# Example B: function using filter
threshold = 6
def predicate(w):
return w > threshold
def g(lst):
return filter(predicate, lst)
# Example C: function using map
# Raise each element of the list to the n-th power.
n = 3
def power(w):
return w**n
def h(lst):
return map(power, lst)
# Example D: function using another list comprehension
# Discard any element of x that is not a
# multiple of a parameter n, and divide the
# elements that are multiples of n by n.
n = 3
def r(lst):
result = []
for w in lst:
if w%n == 0: result.append(w/n)
return result
# EXAMPLES OF OPERATIONS ON STREAMS
# The input stream for these examples
x = Stream('x')
print 'x is the input stream.'
print 'a is a stream consisting of the squares of the input'
print 'b is the stream consisting of values that exceed 6'
print 'c is the stream consisting of the third powers of the input'
print 'd is the stream consisting of values that are multiples of 3 divided by 3'
print 'newa is the same as a. It is defined in a more succinct fashion.'
print 'newb has squares that exceed 6.'
print ''
# The output streams a, b, c, d obtained by
# applying the list operators f, g, h, r to
# stream x.
a = op(f, x)
b = op(g, x)
c = op(h, x)
d = op(r, x)
# You can also define a function only on streams.
# You can do this using functools in Python or
# by simple encapsulation as shown below.
def F(x): return op(f,x)
def G(x): return op(g,x)
newa = F(x)
newb = G(F(x))
# The advantage is that F is a function only
# of streams. So, function composition looks cleaner
# as in G(F(x))
# Name the output streams to label the output
# so that reading the output is easier.
a.set_name('a')
newa.set_name('newa')
b.set_name('b')
newb.set_name('newb')
c.set_name('c')
d.set_name('d')
# At this point x is the empty stream:
# its value is []
x.extend([3, 7])
# Now the value of x is [3, 7]
print "FIRST STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
print ""
x.extend([0, 11, 15])
# Now the value of x is [3, 7, 0, 11, 15]
print "SECOND STEP"
print_streams_recent([x, a, b, c, d, newa, newb])
def <|fim_middle|>():
example_1()
if __name__ == '__main__':
main()
<|fim▁end|> | main |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)<|fim▁hole|>
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])<|fim▁end|> | |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
<|fim_middle|>
<|fim▁end|> | def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0]) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
<|fim_middle|>
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
<|fim_middle|>
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.reset_count += 1 |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
<|fim_middle|>
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB]) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
<|fim_middle|>
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.assertEqual(self.mda.get_memory_size(), 4096) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
<|fim_middle|>
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
<|fim_middle|>
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
<|fim_middle|>
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK)) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
<|fim_middle|>
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK)) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
<|fim_middle|>
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK)) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
<|fim_middle|>
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK)) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
<|fim_middle|>
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
<|fim_middle|>
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
<|fim_middle|>
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.assertEqual(self.mda.mem_read_byte(4000), 0x00) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
<|fim_middle|>
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
<|fim_middle|>
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK)) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
<|fim_middle|>
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK)) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
<|fim_middle|>
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK)) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
<|fim_middle|>
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
<|fim_middle|>
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
<|fim_middle|>
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
<|fim_middle|>
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0]) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
<|fim_middle|>
def test_current_pixel_wraps_bottom(self):
self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0])
<|fim▁end|> | self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1]) |
<|file_name|>test_mda.py<|end_file_name|><|fim▁begin|>import unittest
from pyxt.mda import *
from pyxt.chargen import CharacterGeneratorMock
class MDATests(unittest.TestCase):
def setUp(self):
self.cg = CharacterGeneratorMock(width = 9, height = 14)
self.mda = MonochromeDisplayAdapter(self.cg)
# Hijack reset so it doesn't call into Pygame during the tests.
self.reset_count = 0
self.mda.reset = self.reset_testable
def reset_testable(self):
self.reset_count += 1
def test_ports_list(self):
self.assertEqual(self.mda.get_ports_list(), [0x03B0, 0x03B1, 0x03B2, 0x03B3,
0x03B4, 0x03B5, 0x03B6, 0x03B7,
0x03B8, 0x03B9, 0x03BA, 0x03BB])
def test_get_memory_size(self):
self.assertEqual(self.mda.get_memory_size(), 4096)
def test_initial_state(self):
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.control_reg, 0x00)
self.assertEqual(self.mda.screen, None)
self.assertEqual(self.mda.char_generator, self.cg)
self.assertEqual(len(self.mda.video_ram), 4096)
def test_mem_write_byte_updates_video_ram(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
def test_mem_write_byte_calls_char_generator_top_left(self):
self.mda.mem_write_byte(0x0000, 0x41)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_calls_char_generator_bottom_right(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
def test_mem_write_byte_char_before_attribute(self):
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_attribute_before_char(self):
self.mda.mem_write_byte(3999, MDA_ATTR_INTENSITY)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
self.mda.mem_write_byte(3998, 0xFF)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0xFF, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_byte_write_off_screen(self):
self.mda.mem_write_byte(4000, 0xFF)
self.assertEqual(self.cg.last_blit, None)
def test_mem_read_byte(self):
self.mda.video_ram[77] = 0xA5
self.assertEqual(self.mda.mem_read_byte(77), 0xA5)
def test_mem_read_byte_off_screen(self):
self.assertEqual(self.mda.mem_read_byte(4000), 0x00)
@unittest.skip("We need to initialize Pygame exactly once at startup.")
def test_reset_on_high_resolution_enable(self):
self.assertEqual(self.reset_count, 0)
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
# Second write shouldn't call reset again.
self.mda.io_write_byte(0x3B8, 0x01)
self.assertEqual(self.reset_count, 1)
def test_mem_write_word_at_top_left(self):
self.mda.mem_write_word(0x0000, 0x0841) # 'A' with intensity.
self.assertEqual(self.mda.video_ram[0x0000], 0x41)
self.assertEqual(self.mda.video_ram[0x0001], 0x08)
self.assertEqual(self.cg.last_blit, (None, (0, 0), 0x41, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right(self):
self.mda.mem_write_word(3998, 0x085A) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x5A)
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x5A, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_write_word_at_bottom_right_just_past(self):
self.mda.mem_write_word(3999, 0xFF08) # 'Z' with intensity.
self.assertEqual(self.mda.video_ram[3998], 0x00) # Should be unmodified.
self.assertEqual(self.mda.video_ram[3999], 0x08)
self.assertEqual(self.cg.last_blit, (None, (711, 336), 0x00, MDA_BRIGHT_GREEN, MDA_BLACK))
def test_mem_read_word(self):
self.mda.video_ram[0x0000] = 0x41
self.mda.video_ram[0x0001] = 0x08
self.assertEqual(self.mda.mem_read_word(0x0000), 0x0841)
def test_mem_read_word_just_past_the_end(self):
self.mda.video_ram[3998] = 0x12
self.mda.video_ram[3999] = 0x34
self.assertEqual(self.mda.mem_read_word(3999), 0x0034)
def test_horizontal_retrace_toggles(self):
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF1)
self.assertEqual(self.mda.io_read_byte(0x3BA), 0xF0)
def test_current_pixel_updates_on_status_read(self):
self.assertEqual(self.mda.current_pixel, [0, 0])
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [1, 0])
def test_current_pixel_wraps_right(self):
self.mda.current_pixel = [719, 0]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 1])
def test_current_pixel_wraps_bottom(self):
<|fim_middle|>
<|fim▁end|> | self.mda.current_pixel = [719, 349]
self.mda.io_read_byte(0x3BA)
self.assertEqual(self.mda.current_pixel, [0, 0]) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.