From d44a43f33fa88821b32ab4c505f4cb1b77c15adc Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 24 Feb 2012 14:41:53 +0100 Subject: Switch PyYAML to proper submodule. --- .gitmodules | 3 + pyyaml | 1 + pyyaml/PyYAMLDocumentation.html | 1659 -------- pyyaml/PyYAMLDocumentation_files/jquery.js | 4376 -------------------- pyyaml/PyYAMLDocumentation_files/pyyaml.png | Bin 2507 -> 0 bytes pyyaml/PyYAMLDocumentation_files/search.js | 62 - pyyaml/PyYAMLDocumentation_files/trac.css | 576 --- pyyaml/PyYAMLDocumentation_files/trac.js | 75 - .../PyYAMLDocumentation_files/trac_logo_mini.png | Bin 689 -> 0 bytes pyyaml/PyYAMLDocumentation_files/wiki.css | 51 - pyyaml/YAMLish.html | 353 -- pyyaml/YAMLish_files/commonPrint.css | 290 -- pyyaml/YAMLish_files/gnu-fdl.png | Bin 1748 -> 0 bytes pyyaml/YAMLish_files/handheld.css | 1337 ------ pyyaml/YAMLish_files/index.js | 9 - pyyaml/YAMLish_files/poweredby_mediawiki_88x31.png | Bin 1933 -> 0 bytes pyyaml/YAMLish_files/wikibits.js | 1246 ------ 17 files changed, 4 insertions(+), 10034 deletions(-) create mode 160000 pyyaml delete mode 100644 pyyaml/PyYAMLDocumentation.html delete mode 100644 pyyaml/PyYAMLDocumentation_files/jquery.js delete mode 100644 pyyaml/PyYAMLDocumentation_files/pyyaml.png delete mode 100644 pyyaml/PyYAMLDocumentation_files/search.js delete mode 100644 pyyaml/PyYAMLDocumentation_files/trac.css delete mode 100644 pyyaml/PyYAMLDocumentation_files/trac.js delete mode 100644 pyyaml/PyYAMLDocumentation_files/trac_logo_mini.png delete mode 100644 pyyaml/PyYAMLDocumentation_files/wiki.css delete mode 100644 pyyaml/YAMLish.html delete mode 100644 pyyaml/YAMLish_files/commonPrint.css delete mode 100644 pyyaml/YAMLish_files/gnu-fdl.png delete mode 100644 pyyaml/YAMLish_files/handheld.css delete mode 100644 pyyaml/YAMLish_files/index.js delete mode 100644 pyyaml/YAMLish_files/poweredby_mediawiki_88x31.png delete mode 100644 pyyaml/YAMLish_files/wikibits.js diff --git a/.gitmodules b/.gitmodules index f8ab3c6..53a91e7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "Data--YAML"] path = Data--YAML url = git://github.com/AndyA/Data--YAML.git +[submodule "pyyaml"] + path = pyyaml + url = git@gitorious.org:yamlish/pyyaml.git diff --git a/pyyaml b/pyyaml new file mode 160000 index 0000000..73af245 --- /dev/null +++ b/pyyaml @@ -0,0 +1 @@ +Subproject commit 73af245b205fd9ede7e2fbd32a4de90a17d9baed diff --git a/pyyaml/PyYAMLDocumentation.html b/pyyaml/PyYAMLDocumentation.html deleted file mode 100644 index eaf72e3..0000000 --- a/pyyaml/PyYAMLDocumentation.html +++ /dev/null @@ -1,1659 +0,0 @@ - - - - - PyYAMLDocumentation – PyYAML - - - - - - - - - - - - - - - - -
- -
-
- -

PyYAML Documentation

-

-RPG-ish descriptions are stolen from  the Angband rogue-like game. -Names of the heroes are generated with  MudNames. -

-

-This documentation is very brief and incomplete. Feel free to fix or improve it. -

-

-

-

-

Installation

-

-Download the source package PyYAML-3.08.tar.gz and unpack it. Go to the directory PyYAML-3.08 -and run -

-
$ python setup.py install
-

-If you want to use LibYAML bindings, which are much faster than the pure Python version, you need to -download and install LibYAML. Then you may build and install the bindings by executing -

-
$ python setup.py --with-libyaml install
-

-In order to use LibYAML based parser and emitter, use the classes CParser and CEmitter. -For instance, -

-
from yaml import load, dump
-try:
-    from yaml import CLoader as Loader, CDumper as Dumper
-except ImportError:
-    from yaml import Loader, Dumper
-
-# ...
-
-data = load(stream, Loader=Loader)
-
-# ...
-
-output = dump(data, Dumper=Dumper)
-

-Note that there are some subtle (but not really significant) differences between pure Python and LibYAML based parsers -and emitters. -

-

Frequently Asked Questions

-

Dictionaries without nested collections are not dumped correctly

-

-Why does -

-
import yaml
-document = """
-  a: 1
-  b:
-    c: 3
-    d: 4
-"""
-print yaml.dump(yaml.load(document))
-

-give -

-
a: 1
-b: {c: 3, d: 4}
-

-(see #18, #24)? -

-

-It's a correct output despite the fact that the style of the nested mapping is different. -

-

-By default, PyYAML chooses the style of a collection depending on whether it has nested -collections. If a collection has nested collections, it will be assigned the block style. -Otherwise it will have the flow style. -

-

-If you want collections to be always serialized in the block style, set the parameter -default_flow_style of dump() to False. For instance, -

-
>>> print yaml.dump(yaml.load(document), default_flow_style=False)
-a: 1
-b:
-  c: 3
-  d: 4
-

Python 3 support

-

-Starting from the 3.08 release, PyYAML and LibYAML bindings provide a complete support -for Python 3. This is a short outline of differences in PyYAML API between Python 2 -and Python 3 versions. -

-

-In Python 2: -

-
  • str objects are converted into !!str, !!python/str -or !binary nodes depending on whether the object is an ASCII, UTF-8 -or binary string. -
  • unicode objects are converted into !!python/unicode or -!!str nodes depending on whether the object is an ASCII string or not. -
  • yaml.dump(data) produces the document as a UTF-8 encoded str object. -
  • yaml.dump(data, encoding=('utf-8'|'utf-16-be'|'utf-16-le')) produces -a str object in the specified encoding. -
  • yaml.dump(data, encoding=None) produces a unicode object. -

-In Python 3: -

-
  • str objects are converted to !!str nodes. -
  • bytes objects are converted to !!binary nodes. -
  • For compatibility reasons, !!python/str and !python/unicode tags are -still supported and the corresponding nodes are converted to str objects. -
  • yaml.dump(data) produces the document as a str object. -
  • yaml.dump(data, encoding=('utf-8'|'utf-16-be'|'utf-16-le')) produces -a bytes object in the specified encoding. -

Tutorial

-

-Start with importing the yaml package. -

-
>>> import yaml
-

Loading YAML

-

-Warning: It is not safe to call yaml.load with any data received from an untrusted source! -yaml.load is as powerful as pickle.load and so may call any Python function. -Check the yaml.safe_load function though. -

-

-The function yaml.load converts a YAML document to a Python object. -

-
>>> yaml.load("""
-... - Hesperiidae
-... - Papilionidae
-... - Apatelodidae
-... - Epiplemidae
-... """)
-
-['Hesperiidae', 'Papilionidae', 'Apatelodidae', 'Epiplemidae']
-

-yaml.load accepts a byte string, a Unicode string, an open binary file object, -or an open text file object. A byte string or a file must be encoded with utf-8, -utf-16-be or utf-16-le encoding. yaml.load detects the encoding -by checking the BOM (byte order mark) sequence at the beginning of the -string/file. If no BOM is present, the utf-8 encoding is assumed. -

-

-yaml.load returns a Python object. -

-
>>> yaml.load(u"""
-... hello: Привет!
-... """)    # In Python 3, do not use the 'u' prefix
-
-{'hello': u'\u041f\u0440\u0438\u0432\u0435\u0442!'}
-
->>> stream = file('document.yaml', 'r')    # 'document.yaml' contains a single YAML document.
->>> yaml.load(stream)
-[...]    # A Python object corresponding to the document.
-

-If a string or a file contains several documents, you may load them all with the -yaml.load_all function. -

-
>>> documents = """
-... ---
-... name: The Set of Gauntlets 'Pauraegen'
-... description: >
-...     A set of handgear with sparks that crackle
-...     across its knuckleguards.
-... ---
-... name: The Set of Gauntlets 'Paurnen'
-... description: >
-...   A set of gauntlets that gives off a foul,
-...   acrid odour yet remains untarnished.
-... ---
-... name: The Set of Gauntlets 'Paurnimmen'
-... description: >
-...   A set of handgear, freezing with unnatural cold.
-... """
-
->>> for data in yaml.load_all(documents):
-...     print data
-
-{'description': 'A set of handgear with sparks that crackle across its knuckleguards.\n',
-'name': "The Set of Gauntlets 'Pauraegen'"}
-{'description': 'A set of gauntlets that gives off a foul, acrid odour yet remains untarnished.\n',
-'name': "The Set of Gauntlets 'Paurnen'"}
-{'description': 'A set of handgear, freezing with unnatural cold.\n',
-'name': "The Set of Gauntlets 'Paurnimmen'"}
-

-PyYAML allows you to construct a Python object of any type. -

-
>>> yaml.load("""
-... none: [~, null]
-... bool: [true, false, on, off]
-... int: 42
-... float: 3.14159
-... list: [LITE, RES_ACID, SUS_DEXT]
-... dict: {hp: 13, sp: 5}
-... """)
-
-{'none': [None, None], 'int': 42, 'float': 3.1415899999999999,
-'list': ['LITE', 'RES_ACID', 'SUS_DEXT'], 'dict': {'hp': 13, 'sp': 5},
-'bool': [True, False, True, False]}
-

-Even instances of Python classes can be constructed using the !!python/object tag. -

-
>>> class Hero:
-...     def __init__(self, name, hp, sp):
-...         self.name = name
-...         self.hp = hp
-...         self.sp = sp
-...     def __repr__(self):
-...         return "%s(name=%r, hp=%r, sp=%r)" % (
-...             self.__class__.__name__, self.name, self.hp, self.sp)
-
->>> yaml.load("""
-... !!python/object:__main__.Hero
-... name: Welthyr Syxgon
-... hp: 1200
-... sp: 0
-... """)
-
-Hero(name='Welthyr Syxgon', hp=1200, sp=0)
-

-Note that the ability to construct an arbitrary Python object may be dangerous -if you receive a YAML document from an untrusted source such as Internet. -The function yaml.safe_load limits this ability to simple Python objects -like integers or lists. -

-

-A python object can be marked as safe and thus be recognized by yaml.safe_load. -To do this, derive it from yaml.YAMLObject (as explained in section -Constructors, representers, resolvers) and explicitly set its class property -yaml_loader to yaml.SafeLoader. -

-

Dumping YAML

-

-The yaml.dump function accepts a Python object and produces a YAML document. -

-
>>> print yaml.dump({'name': 'Silenthand Olleander', 'race': 'Human',
-... 'traits': ['ONE_HAND', 'ONE_EYE']})
-
-name: Silenthand Olleander
-race: Human
-traits: [ONE_HAND, ONE_EYE]
-

-yaml.dump accepts the second optional argument, which must be an open text -or binary file. In this case, yaml.dump will write the produced YAML document -into the file. Otherwise, yaml.dump returns the produced document. -

-
>>> stream = file('document.yaml', 'w')
->>> yaml.dump(data, stream)    # Write a YAML representation of data to 'document.yaml'.
->>> print yaml.dump(data)      # Output the document to the screen.
-

-If you need to dump several YAML documents to a single stream, use the function -yaml.dump_all. yaml.dump_all accepts a list or a generator producing -

-

-Python objects to be serialized into a YAML document. The second optional argument is -an open file. -

-
>>> print yaml.dump([1,2,3], explicit_start=True)
---- [1, 2, 3]
-
->>> print yaml.dump_all([1,2,3], explicit_start=True)
---- 1
---- 2
---- 3
-

-You may even dump instances of Python classes. -

-
>>> class Hero:
-...     def __init__(self, name, hp, sp):
-...         self.name = name
-...         self.hp = hp
-...         self.sp = sp
-...     def __repr__(self):
-...         return "%s(name=%r, hp=%r, sp=%r)" % (
-...             self.__class__.__name__, self.name, self.hp, self.sp)
-
->>> print yaml.dump(Hero("Galain Ysseleg", hp=-3, sp=2))
-
-!!python/object:__main__.Hero {hp: -3, name: Galain Ysseleg, sp: 2}
-

-yaml.dump supports a number of keyword arguments that specify -formatting details for the emitter. For instance, you may set the -preferred intendation and width, use the canonical YAML format or -force preferred style for scalars and collections. -

-
>>> print yaml.dump(range(50))
-[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
-  23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
-  43, 44, 45, 46, 47, 48, 49]
-
->>> print yaml.dump(range(50), width=50, indent=4)
-[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
-    16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
-    28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
-    40, 41, 42, 43, 44, 45, 46, 47, 48, 49]
-
->>> print yaml.dump(range(5), canonical=True)
----
-!!seq [
-  !!int "0",
-  !!int "1",
-  !!int "2",
-  !!int "3",
-  !!int "4",
-]
-
->>> print yaml.dump(range(5), default_flow_style=False)
-- 0
-- 1
-- 2
-- 3
-- 4
-
->>> print yaml.dump(range(5), default_flow_style=True, default_style='"')
-[!!int "0", !!int "1", !!int "2", !!int "3", !!int "4"]
-

Constructors, representers, resolvers

-

-You may define your own application-specific tags. The easiest way to do it is -to define a subclass of yaml.YAMLObject: -

-
>>> class Monster(yaml.YAMLObject):
-...     yaml_tag = u'!Monster'
-...     def __init__(self, name, hp, ac, attacks):
-...         self.name = name
-...         self.hp = hp
-...         self.ac = ac
-...         self.attacks = attacks
-...     def __repr__(self):
-...         return "%s(name=%r, hp=%r, ac=%r, attacks=%r)" % (
-...             self.__class__.__name__, self.name, self.hp, self.ac, self.attacks)
-

-The above definition is enough to automatically load and dump Monster objects: -

-
>>> yaml.load("""
-... --- !Monster
-... name: Cave spider
-... hp: [2,6]    # 2d6
-... ac: 16
-... attacks: [BITE, HURT]
-... """)
-
-Monster(name='Cave spider', hp=[2, 6], ac=16, attacks=['BITE', 'HURT'])
-
->>> print yaml.dump(Monster(
-...     name='Cave lizard', hp=[3,6], ac=16, attacks=['BITE','HURT']))
-
-!Monster
-ac: 16
-attacks: [BITE, HURT]
-hp: [3, 6]
-name: Cave lizard
-

-yaml.YAMLObject uses metaclass magic to register a constructor, which -transforms a YAML node to a class instance, and a representer, which serializes -a class instance to a YAML node. -

-

-If you don't want to use metaclasses, you may register your constructors -and representers using the functions yaml.add_constructor and -yaml.add_representer. For instance, you may want to add a constructor -and a representer for the following Dice class: -

-
>>> class Dice(tuple):
-...     def __new__(cls, a, b):
-...         return tuple.__new__(cls, [a, b])
-...     def __repr__(self):
-...         return "Dice(%s,%s)" % self
-
->>> print Dice(3,6)
-Dice(3,6)
-

-The default representation for Dice objects is not nice: -

-
>>> print yaml.dump(Dice(3,6))
-
-!!python/object/new:__main__.Dice
-- !!python/tuple [3, 6]
-

-Suppose you want a Dice object to represented as AdB in YAML: -

-
>>> print yaml.dump(Dice(3,6))
-
-3d6
-

-First we define a representer that convert a dice object to scalar node -with the tag !dice and register it. -

-
>>> def dice_representer(dumper, data):
-...     return dumper.represent_scalar(u'!dice', u'%sd%s' % data)
-
->>> yaml.add_representer(Dice, dice_representer)
-

-Now you may dump an instance of the Dice object: -

-
>>> print yaml.dump({'gold': Dice(10,6)})
-{gold: !dice '10d6'}
-

-Let us add the code to construct a Dice object: -

-
>>> def dice_constructor(loader, node):
-...     value = loader.construct_scalar(node)
-...     a, b = map(int, value.split('d'))
-...     return Dice(a, b)
-
->>> yaml.add_constructor(u'!dice', dice_constructor)
-

-Then you may load a Dice object as well: -

-
>>> print yaml.load("""
-... initial hit points: !dice 8d4
-... """)
-
-{'initial hit points': Dice(8,4)}
-

-You might want to not specify the tag !dice everywhere. There is a way -to teach PyYAML that any untagged plain scalar that looks like XdY has -the implicit tag !dice. Use add_implicit_resolver: -

-
>>> import re
->>> pattern = re.compile(r'^\d+d\d+$')
->>> yaml.add_implicit_resolver(u'!dice', pattern)
-

-Now you don't have to specify the tag to define a Dice object: -

-
>>> print yaml.dump({'treasure': Dice(10,20)})
-
-{treasure: 10d20}
-
->>> print yaml.load("""
-... damage: 5d10
-... """)
-
-{'damage': Dice(5,10)}
-

YAML syntax

-

-A good introduction to the YAML syntax is - Chapter 2 of the YAML specification. -

-

-You may also check  the YAML cookbook. Note -that it is focused on a Ruby implementation and uses the old YAML 1.0 syntax. -

-

-Here we present most common YAML constructs together with the corresponding Python objects. -

-

Documents

-

-YAML stream is a collection of zero or more documents. An empty stream contains no documents. -Documents are separated with ---. Documents may optionally end with .... -A single document may or may not be marked with ---. -

-

-Example of an implicit document: -

-
- Multimedia
-- Internet
-- Education
-

-Example of an explicit document: -

-
---
-- Afterstep
-- CTWM
-- Oroborus
-...
-

-Example of several documents in the same stream: -

-
---
-- Ada
-- APL
-- ASP
-
-- Assembly
-- Awk
----
-- Basic
----
-- C
-- C#    # Note that comments are denoted with ' #' (space and #).
-- C++
-- Cold Fusion
-

Block sequences

-

-In the block context, sequence entries are denoted by - (dash and space): -

-
# YAML
-- The Dagger 'Narthanc'
-- The Dagger 'Nimthanc'
-- The Dagger 'Dethanc'
-
# Python
-["The Dagger 'Narthanc'", "The Dagger 'Nimthanc'", "The Dagger 'Dethanc'"]
-

-Block sequences can be nested: -

-
# YAML
--
-  - HTML
-  - LaTeX
-  - SGML
-  - VRML
-  - XML
-  - YAML
--
-  - BSD
-  - GNU Hurd
-  - Linux
-
# Python
-[['HTML', 'LaTeX', 'SGML', 'VRML', 'XML', 'YAML'], ['BSD', 'GNU Hurd', 'Linux']]
-

-It's not necessary to start a nested sequence with a new line: -

-
# YAML
-- 1.1
-- - 2.1
-  - 2.2
-- - - 3.1
-    - 3.2
-    - 3.3
-
# Python
-[1.1, [2.1, 2.2], [[3.1, 3.2, 3.3]]]
-

-A block sequence may be nested to a block mapping. Note that in this -case it is not necessary to indent the sequence. -

-
# YAML
-left hand:
-- Ring of Teleportation
-- Ring of Speed
-
-right hand:
-- Ring of Resist Fire
-- Ring of Resist Cold
-- Ring of Resist Poison
-
# Python
-{'right hand': ['Ring of Resist Fire', 'Ring of Resist Cold', 'Ring of Resist Poison'],
-'left hand': ['Ring of Teleportation', 'Ring of Speed']}
-

Block mappings

-

-In the block context, keys and values of mappings are separated by : (colon and space): -

-
# YAML
-base armor class: 0
-base damage: [4,4]
-plus to-hit: 12
-plus to-dam: 16
-plus to-ac: 0
-
# Python
-{'plus to-hit': 12, 'base damage': [4, 4], 'base armor class': 0, 'plus to-ac': 0, 'plus to-dam': 16}
-

-Complex keys are denoted with ? (question mark and space): -

-
# YAML
-? !!python/tuple [0,0]
-: The Hero
-? !!python/tuple [0,1]
-: Treasure
-? !!python/tuple [1,0]
-: Treasure
-? !!python/tuple [1,1]
-: The Dragon
-
# Python
-{(0, 1): 'Treasure', (1, 0): 'Treasure', (0, 0): 'The Hero', (1, 1): 'The Dragon'}
-

-Block mapping can be nested: -

-
# YAML
-hero:
-  hp: 34
-  sp: 8
-  level: 4
-orc:
-  hp: 12
-  sp: 0
-  level: 2
-
# Python
-{'hero': {'hp': 34, 'sp': 8, 'level': 4}, 'orc': {'hp': 12, 'sp': 0, 'level': 2}}
-

-A block mapping may be nested in a block sequence: -

-
# YAML
-- name: PyYAML
-  status: 4
-  license: MIT
-  language: Python
-- name: PySyck
-  status: 5
-  license: BSD
-  language: Python
-
# Python
-[{'status': 4, 'language': 'Python', 'name': 'PyYAML', 'license': 'MIT'},
-{'status': 5, 'license': 'BSD', 'name': 'PySyck', 'language': 'Python'}]
-

Flow collections

-

-The syntax of flow collections in YAML is very close to the syntax of list and -dictionary constructors in Python: -

-
# YAML
-{ str: [15, 17], con: [16, 16], dex: [17, 18], wis: [16, 16], int: [10, 13], chr: [5, 8] }
-
# Python
-{'dex': [17, 18], 'int': [10, 13], 'chr': [5, 8], 'wis': [16, 16], 'str': [15, 17], 'con': [16, 16]}
-

Scalars

-

-There are 5 styles of scalars in YAML: plain, single-quoted, double-quoted, literal, and folded: -

-
# YAML
-plain: Scroll of Remove Curse
-single-quoted: 'EASY_KNOW'
-double-quoted: "?"
-literal: |    # Borrowed from http://www.kersbergen.com/flump/religion.html
-  by hjw              ___
-     __              /.-.\
-    /  )_____________\\  Y
-   /_ /=== == === === =\ _\_
-  ( /)=== == === === == Y   \
-   `-------------------(  o  )
-                        \___/
-folded: >
-  It removes all ordinary curses from all equipped items.
-  Heavy or permanent curses are unaffected.
-
# Python
-{'plain': 'Scroll of Remove Curse',
-'literal':
-    'by hjw              ___\n'
-    '   __              /.-.\\\n'
-    '  /  )_____________\\\\  Y\n'
-    ' /_ /=== == === === =\\ _\\_\n'
-    '( /)=== == === === == Y   \\\n'
-    ' `-------------------(  o  )\n'
-    '                      \\___/\n',
-'single-quoted': 'EASY_KNOW',
-'double-quoted': '?',
-'folded': 'It removes all ordinary curses from all equipped items. Heavy or permanent curses are unaffected.\n'}
-

-Each style has its own quirks. A plain scalar does not use indicators to denote its -start and end, therefore it's the most restricted style. Its natural applications are -names of attributes and parameters. -

-

-Using single-quoted scalars, you may express any value that does not contain special characters. -No escaping occurs for single quoted scalars except that duplicate quotes '' are replaced -with a single quote '. -

-

-Double-quoted is the most powerful style and the only style that can express any scalar value. -Double-quoted scalars allow escaping. Using escaping sequences \x** and \u****, -you may express any ASCII or Unicode character. -

-

-There are two kind of block scalar styles: literal and folded. The literal style is -the most suitable style for large block of text such as source code. The folded style is similar -to the literal style, but two consequent non-empty lines are joined to a single line separated -by a space character. -

-

Aliases

-

-Note that PyYAML does not yet support recursive objects. -

-

-Using YAML you may represent objects of arbitrary graph-like structures. If you want to refer -to the same object from different parts of a document, you need to use anchors and aliases. -

-

-Anchors are denoted by the & indicator while aliases are denoted by *. For instance, -the document -

-
left hand: &A
-  name: The Bastard Sword of Eowyn
-  weight: 30
-right hand: *A
-

-expresses the idea of a hero holding a heavy sword in both hands. -

-

-PyYAML now fully supports recursive objects. For instance, the document -

-
&A [ *A ]
-

-will produce a list object containing a reference to itself. -

-

Tags

-

-Tags are used to denote the type of a YAML node. Standard YAML tags are defined at - http://yaml.org/type/index.html. -

-

-Tags may be implicit: -

-
boolean: true
-integer: 3
-float: 3.14
-
{'boolean': True, 'integer': 3, 'float': 3.14}
-

-or explicit: -

-
boolean: !!bool "true"
-integer: !!int "3"
-float: !!float "3.14"
-
{'boolean': True, 'integer': 3, 'float': 3.14}
-

-Plain scalars without explicitly defined tag are subject to implicit tag -resolution. The scalar value is checked against a set of regular expressions -

-

-and if one of them matches, the corresponding tag is assigned to the scalar. -PyYAML allows an application to add custom implicit tag resolvers. -

-

YAML tags and Python types

-

-The following table describes how nodes with different tags are converted -to Python objects. -

- -
YAML tag Python type -
Standard YAML tags -
!!null None -
!!bool bool -
!!int int or long (int in Python 3) -
!!float float -
!!binary str (bytes in Python 3) -
!!timestamp datetime.datetime -
!!omap, !!pairs list of pairs -
!!set set -
!!str str or unicode (str in Python 3) -
!!seq list -
!!map dict -
Python-specific tags -
!!python/none None -
!!python/bool bool -
!!python/bytes (bytes in Python 3) -
!!python/str str (str in Python 3) -
!!python/unicode unicode (str in Python 3) -
!!python/int int -
!!python/long long (int in Python 3) -
!!python/float float -
!!python/complex complex -
!!python/list list -
!!python/tuple tuple -
!!python/dict dict -
Complex Python tags -
!!python/name:module.name module.name -
!!python/module:package.module package.module -
!!python/object:module.cls module.cls instance -
!!python/object/new:module.cls module.cls instance -
!!python/object/apply:module.f value of f(...) -
-

String conversion (Python 2 only)

-

-There are four tags that are converted to str and unicode values: -!!str, !!binary, !!python/str, and !!python/unicode. -

-

-!!str-tagged scalars are converted to str objects if its value is ASCII. Otherwise it is converted to unicode. -!!binary-tagged scalars are converted to str objects with its value decoded using the base64 encoding. -!!python/str scalars are converted to str objects encoded with utf-8 encoding. -!!python/unicode scalars are converted to unicode objects. -

-

-Conversely, a str object is converted to -

-
  1. a !!str scalar if its value is ASCII. -
  2. a !!python/str scalar if its value is a correct utf-8 sequence. -
  3. a !!binary scalar otherwise. -

-A unicode object is converted to -

-
  1. a !!python/unicode scalar if its value is ASCII. -
  2. a !!str scalar otherwise. -

String conversion (Python 3 only)

-

-In Python 3, str objects are converted to !!str scalars and bytes objects to !!binary scalars. -For compatibility reasons, tags !!python/str and !!python/unicode are still supported and converted -to str objects. -

-

Names and modules

-

-In order to represent static Python objects like functions or classes, you need to use -a complex !!python/name tag. For instance, the function yaml.dump can be represented as -

-
!!python/name:yaml.dump
-

-Similarly, modules are represented using the tag !python/module: -

-
!!python/module:yaml
-

Objects

-

-Any pickleable object can be serialized using the !!python/object tag: -

-
!!python/object:module.Class { attribute: value, ... }
-

-In order to support the pickle protocol, two additional forms of the !!python/object tag -are provided: -

-
!!python/object/new:module.Class
-args: [argument, ...]
-kwds: {key: value, ...}
-state: ...
-listitems: [item, ...]
-dictitems: [key: value, ...]
-
!!python/object/apply:module.function
-args: [argument, ...]
-kwds: {key: value, ...}
-state: ...
-listitems: [item, ...]
-dictitems: [key: value, ...]
-

-If only the args field is non-empty, the above records can be shortened: -

-
!!python/object/new:module.Class [argument, ...]
-
!!python/object/apply:module.function [argument, ...]
-

Reference

-

-Warning: API stability is not guaranteed''' -

-

The yaml package

-
scan(stream, Loader=Loader)
-

-scan(stream) scans the given stream and produces a sequence of tokens. -

-
parse(stream, Loader=Loader)
-
-emit(events, stream=None, Dumper=Dumper,
-    canonical=None,
-    indent=None,
-    width=None,
-    allow_unicode=None,
-    line_break=None)
-

-parse(stream) parses the given stream and produces a sequence of parsing events. -

-

-emit(events, stream=None) serializes the given sequence of parsing events and -write them to the stream. if stream is None, it returns the produced stream. -

-
compose(stream, Loader=Loader)
-compose_all(stream, Loader=Loader)
-
-serialize(node, stream=None, Dumper=Dumper,
-    encoding='utf-8', # encoding=None (Python 3)
-    explicit_start=None,
-    explicit_end=None,
-    version=None,
-    tags=None,
-    canonical=None,
-    indent=None,
-    width=None,
-    allow_unicode=None,
-    line_break=None)
-serialize_all(nodes, stream=None, Dumper=Dumper, ...)
-

-compose(stream) parses the given stream and returns the root of the representation graph -for the first document in the stream. If there are no documents in the stream, it returns None. -

-

-compose_all(stream) parses the given stream and returns a sequence of representation graphs -corresponding to the documents in the stream. -

-

-serialize(node, stream=None) serializes the given representation graph into the stream. -If stream is None, it returns the produced stream. -

-

-serialize_all(node, stream=None) serializes the given sequence of representation graphs -into the given stream. If stream is None, it returns the produced stream. -

-
load(stream, Loader=Loader)
-load_all(stream, Loader=Loader)
-
-safe_load(stream)
-safe_load_all(stream)
-
-dump(data, stream=None, Dumper=Dumper,
-    default_style=None,
-    default_flow_style=None,
-    encoding='utf-8', # encoding=None (Python 3)
-    explicit_start=None,
-    explicit_end=None,
-    version=None,
-    tags=None,
-    canonical=None,
-    indent=None,
-    width=None,
-    allow_unicode=None,
-    line_break=None)
-dump_all(data, stream=None, Dumper=Dumper, ...)
-
-safe_dump(data, stream=None, ...)
-safe_dump_all(data, stream=None, ...)
-

-load(stream) parses the given stream and returns a Python object constructed from -for the first document in the stream. If there are no documents in the stream, it returns None. -

-

-load_all(stream) parses the given stream and returns a sequence of Python objects -corresponding to the documents in the stream. -

-

-safe_load(stream) parses the given stream and returns a Python object constructed from -for the first document in the stream. If there are no documents in the stream, it returns None. -safe_load recognizes only standard YAML tags and cannot construct an arbitrary Python object. -

-

-A python object can be marked as safe and thus be recognized by yaml.safe_load. -To do this, derive it from yaml.YAMLObject (as explained in section -Constructors, representers, resolvers) and explicitly set its class property -yaml_loader to yaml.SafeLoader. -

-

-safe_load_all(stream) parses the given stream and returns a sequence of Python objects -corresponding to the documents in the stream. safe_load_all recognizes only standard YAML tags -and cannot construct an arbitrary Python object. -

-

-dump(data, stream=None) serializes the given Python object into the stream. -If stream is None, it returns the produced stream. -

-

-dump_all(data, stream=None) serializes the given sequence of Python objects -into the given stream. If stream is None, it returns the produced stream. -Each object is represented as a YAML document. -

-

-safe_dump(data, stream=None) serializes the given Python object into the stream. -If stream is None, it returns the produced stream. safe_dump produces only standard YAML -tags and cannot represent an arbitrary Python object. -

-

-safe_dump_all(data, stream=None) serializes the given sequence of Python objects -into the given stream. If stream is None, it returns the produced stream. -Each object is represented as a YAML document. safe_dump_all produces only standard YAML -tags and cannot represent an arbitrary Python object. -

-
def constructor(loader, node):
-    # ...
-    return data
-
-def multi_constructor(loader, tag_suffix, node):
-    # ...
-    return data
-
-add_constructor(tag, constructor, Loader=Loader)
-add_multi_constructor(tag_prefix, multi_constructor, Loader=Loader)
-

-add_constructor(tag, constructor) allows to specify a constructor for the given tag. -A constructor is a function that converts a node of a YAML representation graph to a native Python object. -A constructor accepts an instance of Loader and a node and returns a Python object. -

-

-add_multi_constructor(tag_prefix, multi_constructor) allows to specify a multi_constructor -for the given tag_prefix. A multi-constructor is a function that converts a node of a YAML -representation graph to a native Python object. A multi-constructor accepts an instance of Loader, -the suffix of the node tag, and a node and returns a Python object. -

-
def representer(dumper, data):
-    # ...
-    return node
-
-def multi_representer(dumper, data):
-    # ...
-    return node
-
-add_representer(data_type, representer, Dumper=Dumper)
-add_multi_representer(base_data_type, multi_representer, Dumper=Dumper)
-

-add_representer(data_type, representer) allows to specify a representer for Python objects -of the given data_type. A representer is a function that converts a native Python object to a node -of a YAML representation graph. A representer accepts an instance of Dumper and an object and returns a node. -

-

-add_multi_representer(base_data_type, multi_representer) allows to specify a multi_representer -for Python objects of the given base_data_type or any of its subclasses. A multi-representer is -a function that converts a native Python object to a node of a YAML representation graph. -A multi-representer accepts an instance of Dumper and an object and returns a node. -

-
add_implicit_resolver(tag, regexp, first, Loader=Loader, Dumper=Dumper)
-add_path_resolver(tag, path, kind, Loader=Loader, Dumper=Dumper)
-

-add_implicit_resolver(tag, regexp, first) adds an implicit tag resolver for plain scalars. -If the scalar value is matched the given regexp, it is assigned the tag. first is a -list of possible initial characters or None. -

-

-add_path_resolver(tag, path, kind) adds a path-based implicit tag resolver. -A path is a list of keys that form a path to a node in the representation graph. -Paths elements can be string values, integers, or None. The kind of a node can -be str, list, dict, or None. -

-

Mark

-
Mark(name, index, line, column, buffer, pointer)
-

-An instance of Mark points to a certain position in the input stream. name is -the name of the stream, for instance it may be the filename if the input stream is a file. -line and column is the line and column of the position (starting from 0). -buffer, when it is not None, is a part of the input stream that contain the position -and pointer refers to the position in the buffer. -

-

YAMLError

-
YAMLError()
-

-If the YAML parser encounters an error condition, it raises an exception which is an instance of -YAMLError or of its subclass. An application may catch this exception and warn a user. -

-
try:
-    config = yaml.load(file('config.yaml', 'r'))
-except yaml.YAMLError, exc:
-    print "Error in configuration file:", exc
-

-An exception produced by the YAML processor may point to the problematic position. -

-
>>> try:
-...     yaml.load("unbalanced blackets: ][")
-... except yaml.YAMLError, exc:
-...     if hasattr(exc, 'problem_mark'):
-...         mark = exc.problem_mark
-...         print "Error position: (%s:%s)" % (mark.line+1, mark.column+1)
-
-Error position: (1:22)
-

Tokens

-

-Tokens are produced by a YAML scanner. They are not really useful except for low-level YAML -applications such as syntax highlighting. -

-

-The PyYAML scanner produces the following types of tokens: -

-
StreamStartToken(encoding, start_mark, end_mark) # Start of the stream.
-StreamEndToken(start_mark, end_mark) # End of the stream.
-DirectiveToken(name, value, start_mark, end_mark) # YAML directive, either %YAML or %TAG.
-DocumentStartToken(start_mark, end_mark) # '---'.
-DocumentEndToken(start_mark, end_mark) # '...'.
-BlockSequenceStartToken(start_mark, end_mark) # Start of a new block sequence.
-BlockMappingStartToken(start_mark, end_mark) # Start of a new block mapping.
-BlockEndToken(start_mark, end_mark) # End of a block collection.
-FlowSequenceStartToken(start_mark, end_mark) # '['.
-FlowMappingStartToken(start_mark, end_mark) # '{'.
-FlowSequenceEndToken(start_mark, end_mark) # ']'.
-FlowMappingEndToken(start_mark, end_mark) # '}'.
-KeyToken(start_mark, end_mark) # Either '?' or start of a simple key.
-ValueToken(start_mark, end_mark) # ':'.
-BlockEntryToken(start_mark, end_mark) # '-'.
-FlowEntryToken(start_mark, end_mark) # ','.
-AliasToken(value, start_mark, end_mark) # '*value'.
-AnchorToken(value, start_mark, end_mark) # '&value'.
-TagToken(value, start_mark, end_mark) # '!value'.
-ScalarToken(value, plain, style, start_mark, end_mark) # 'value'.
-

-start_mark and end_mark denote the beginning and the end of a token. -

-

-Example: -

-
>>> document = """
-... ---
-... block sequence:
-... - BlockEntryToken
-... block mapping:
-...   ? KeyToken
-...   : ValueToken
-... flow sequence: [FlowEntryToken, FlowEntryToken]
-... flow mapping: {KeyToken: ValueToken}
-... anchors and tags:
-... - &A !!int '5'
-... - *A
-... ...
-... """
-
->>> for token in yaml.scan(document):
-...     print token
-
-StreamStartToken(encoding='utf-8')
-
-DocumentStartToken()
-
-BlockMappingStartToken()
-
-KeyToken()
-ScalarToken(plain=True, style=None, value=u'block sequence')
-
-ValueToken()
-BlockEntryToken()
-ScalarToken(plain=True, style=None, value=u'BlockEntryToken')
-
-KeyToken()
-ScalarToken(plain=True, style=None, value=u'block mapping')
-
-ValueToken()
-BlockMappingStartToken()
-
-KeyToken()
-ScalarToken(plain=True, style=None, value=u'KeyToken')
-ValueToken()
-ScalarToken(plain=True, style=None, value=u'ValueToken')
-BlockEndToken()
-
-KeyToken()
-ScalarToken(plain=True, style=None, value=u'flow sequence')
-
-ValueToken()
-FlowSequenceStartToken()
-ScalarToken(plain=True, style=None, value=u'FlowEntryToken')
-FlowEntryToken()
-ScalarToken(plain=True, style=None, value=u'FlowEntryToken')
-FlowSequenceEndToken()
-
-KeyToken()
-ScalarToken(plain=True, style=None, value=u'flow mapping')
-
-ValueToken()
-FlowMappingStartToken()
-KeyToken()
-ScalarToken(plain=True, style=None, value=u'KeyToken')
-ValueToken()
-ScalarToken(plain=True, style=None, value=u'ValueToken')
-FlowMappingEndToken()
-
-KeyToken()
-ScalarToken(plain=True, style=None, value=u'anchors and tags')
-
-ValueToken()
-BlockEntryToken()
-AnchorToken(value=u'A')
-TagToken(value=(u'!!', u'int'))
-ScalarToken(plain=False, style="'", value=u'5')
-
-BlockEntryToken()
-AliasToken(value=u'A')
-
-BlockEndToken()
-
-DocumentEndToken()
-
-StreamEndToken()
-

Events

-

-Events are used by the low-level Parser and Emitter interfaces, which are similar to the SAX API. -While the Parser parses a YAML stream and produces a sequence of events, the Emitter accepts -a sequence of events and emits a YAML stream. -

-

-The following events are defined: -

-
StreamStartEvent(encoding, start_mark, end_mark)
-StreamEndEvent(start_mark, end_mark)
-DocumentStartEvent(explicit, version, tags, start_mark, end_mark)
-DocumentEndEvent(start_mark, end_mark)
-SequenceStartEvent(anchor, tag, implicit, flow_style, start_mark, end_mark)
-SequenceEndEvent(start_mark, end_mark)
-MappingStartEvent(anchor, tag, implicit, flow_style, start_mark, end_mark)
-MappingEndEvent(start_mark, end_mark)
-AliasEvent(anchor, start_mark, end_mark)
-ScalarEvent(anchor, tag, implicit, value, style, start_mark, end_mark)
-

-The flow_style flag indicates if a collection is block or flow. The possible values are -None, True, False. The style flag of a scalar event indicates the style of the scalar. -Possible values are None, '', '\'', '"', '|', '>'. The implicit flag of a collection -start event indicates if the tag may be omitted when the collection is emitted. The implicit flag -of a scalar event is a pair of boolean values that indicate if the tag may be omitted when the scalar -is emitted in a plain and non-plain style correspondingly. -

-

-Example: -

-
>>> document = """
-... scalar: &A !!int '5'
-... alias: *A
-... sequence: [1, 2, 3]
-... mapping: [1: one, 2: two, 3: three]
-... """
-
->>> for event in yaml.parse(document):
-...     print event
-
-StreamStartEvent()
-
-DocumentStartEvent()
-
-MappingStartEvent(anchor=None, tag=None, implicit=True)
-
-ScalarEvent(anchor=None, tag=None, implicit=(True, False), value=u'scalar')
-ScalarEvent(anchor=u'A', tag=u'tag:yaml.org,2002:int', implicit=(False, False), value=u'5')
-
-ScalarEvent(anchor=None, tag=None, implicit=(True, False), value=u'alias')
-AliasEvent(anchor=u'A')
-
-ScalarEvent(anchor=None, tag=None, implicit=(True, False), value=u'sequence')
-SequenceStartEvent(anchor=None, tag=None, implicit=True)
-ScalarEvent(anchor=None, tag=None, implicit=(True, False), value=u'1')
-ScalarEvent(anchor=None, tag=None, implicit=(True, False), value=u'2')
-ScalarEvent(anchor=None, tag=None, implicit=(True, False), value=u'3')
-SequenceEndEvent()
-
-ScalarEvent(anchor=None, tag=None, implicit=(True, False), value=u'mapping')
-MappingStartEvent(anchor=None, tag=None, implicit=True)
-ScalarEvent(anchor=None, tag=None, implicit=(True, False), value=u'1')
-ScalarEvent(anchor=None, tag=None, implicit=(True, False), value=u'one')
-ScalarEvent(anchor=None, tag=None, implicit=(True, False), value=u'2')
-ScalarEvent(anchor=None, tag=None, implicit=(True, False), value=u'two')
-ScalarEvent(anchor=None, tag=None, implicit=(True, False), value=u'3')
-ScalarEvent(anchor=None, tag=None, implicit=(True, False), value=u'three')
-MappingEndEvent()
-
-MappingEndEvent()
-
-DocumentEndEvent()
-
-StreamEndEvent()
-
->>> print yaml.emit([
-...     yaml.StreamStartEvent(encoding='utf-8'),
-...     yaml.DocumentStartEvent(explicit=True),
-...     yaml.MappingStartEvent(anchor=None, tag=u'tag:yaml.org,2002:map', implicit=True, flow_style=False),
-...     yaml.ScalarEvent(anchor=None, tag=u'tag:yaml.org,2002:str', implicit=(True, True), value=u'agile languages'),
-...     yaml.SequenceStartEvent(anchor=None, tag=u'tag:yaml.org,2002:seq', implicit=True, flow_style=True),
-...     yaml.ScalarEvent(anchor=None, tag=u'tag:yaml.org,2002:str', implicit=(True, True), value=u'Python'),
-...     yaml.ScalarEvent(anchor=None, tag=u'tag:yaml.org,2002:str', implicit=(True, True), value=u'Perl'),
-...     yaml.ScalarEvent(anchor=None, tag=u'tag:yaml.org,2002:str', implicit=(True, True), value=u'Ruby'),
-...     yaml.SequenceEndEvent(),
-...     yaml.MappingEndEvent(),
-...     yaml.DocumentEndEvent(explicit=True),
-...     yaml.StreamEndEvent(),
-... ])
-
----
-agile languages: [Python, Perl, Ruby]
-...
-

Nodes

-

-Nodes are entities in the YAML informational model. There are three kinds of nodes: -scalar, sequence, and mapping. In PyYAML, nodes are produced by Composer -and can be serialized to a YAML stream by Serializer. -

-
ScalarNode(tag, value, style, start_mark, end_mark)
-SequenceNode(tag, value, flow_style, start_mark, end_mark)
-MappingNode(tag, value, flow_style, start_mark, end_mark)
-

-The style and flow_style flags have the same meaning as for events. -The value of a scalar node must be a unicode string. The value of a sequence node is -a list of nodes. The value of a mapping node is a list of pairs consisting of key and -value nodes. -

-

-Example: -

-
>>> print yaml.compose("""
-... kinds:
-... - scalar
-... - sequence
-... - mapping
-... """)
-
-MappingNode(tag=u'tag:yaml.org,2002:map', value=[
-    (ScalarNode(tag=u'tag:yaml.org,2002:str', value=u'kinds'), SequenceNode(tag=u'tag:yaml.org,2002:seq', value=[
-        ScalarNode(tag=u'tag:yaml.org,2002:str', value=u'scalar'),
-        ScalarNode(tag=u'tag:yaml.org,2002:str', value=u'sequence'),
-        ScalarNode(tag=u'tag:yaml.org,2002:str', value=u'mapping')]))])
-
->>> print yaml.serialize(yaml.SequenceNode(tag=u'tag:yaml.org,2002:seq', value=[
-...     yaml.ScalarNode(tag=u'tag:yaml.org,2002:str', value=u'scalar'),
-...     yaml.ScalarNode(tag=u'tag:yaml.org,2002:str', value=u'sequence'),
-...     yaml.ScalarNode(tag=u'tag:yaml.org,2002:str', value=u'mapping')]))
-
-- scalar
-- sequence
-- mapping
-

Loader

-
Loader(stream)
-SafeLoader(stream)
-BaseLoader(stream)
-
-# The following classes are available only if you build LibYAML bindings.
-CLoader(stream)
-CSafeLoader(stream)
-CBaseLoader(stream)
-

-Loader(stream) is the most common of the above classes and should be used in most cases. -stream is an input YAML stream. It can be a string, a Unicode string, an open file, an open Unicode file. -

-

-Loader supports all predefined tags and may construct an arbitrary Python object. Therefore it is not safe to use -Loader to load a document received from an untrusted source. By default, the functions scan, parse, -compose, construct, and others use Loader. -

-

-SafeLoader(stream) supports only standard YAML tags and thus it does not construct class instances and -probably safe to use with documents received from an untrusted source. The functions safe_load and -safe_load_all use SafeLoader to parse a stream. -

-

-BaseLoader(stream) does not resolve or support any tags and construct only basic Python objects: -lists, dictionaries and Unicode strings. -

-

-CLoader, CSafeLoader, CBaseLoader are versions of the above classes written in C -using the LibYAML library. -

-
Loader.check_token(*TokenClasses)
-Loader.peek_token()
-Loader.get_token()
-

-Loader.check_token(*TokenClasses) returns True if the next token in the stream -is an instance of one of the given TokenClasses. Otherwise it returns False. -

-

-Loader.peek_token() returns the next token in the stream, but does not remove -it from the internal token queue. The function returns None at the end of the stream. -

-

-Loader.get_token() returns the next token in the stream and removes -it from the internal token queue. The function returns None at the end of the stream. -

-
Loader.check_event(*EventClasses)
-Loader.peek_event()
-Loader.get_event()
-

-Loader.check_event(*EventClasses) returns True if the next event in the stream -is an instance of one of the given EventClasses. Otherwise it returns False. -

-

-Loader.peek_event() returns the next event in the stream, but does not remove -it from the internal event queue. The function returns None at the end of the stream. -

-

-Loader.get_event() returns the next event in the stream and removes -it from the internal event queue. The function returns None at the end of the stream. -

-
Loader.check_node()
-Loader.get_node()
-

-Loader.check_node() returns True is there are more documents available in the stream. Otherwise -it returns False. -

-

-Loader.get_node() construct the representation graph of the next document in the stream and -returns its root node. -

-
Loader.check_data()
-Loader.get_data()
-
-Loader.add_constructor(tag, constructor) # Loader.add_constructor is a class method.
-Loader.add_multi_constructor(tag_prefix, multi_constructor) # Loader.add_multi_constructor is a class method.
-
-Loader.construct_scalar(node)
-Loader.construct_sequence(node)
-Loader.construct_mapping(node)
-

-Loader.check_data() returns True is there are more documents available in the stream. Otherwise -it returns False. -

-

-Loader.get_data() constructs and returns a Python object corresponding to the next document -in the stream. -

-

-Loader.add_constructor(tag, constructor): see add_constructor. -

-

-Loader.add_multi_constructor(tag_prefix, multi_constructor): see add_multi_constructor. -

-

-Loader.construct_scalar(node) checks that the given node is a scalar and returns its value. -This function is intended to be used in constructors. -

-

-Loader.construct_sequence(node) checks that the given node is a sequence and returns a list -of Python objects corresponding to the node items. This function is intended to be used in constructors. -

-

-Loader.construct_mapping(node) checks that the given node is a mapping and returns a dictionary -of Python objects corresponding to the node keys and values. This function is intended to be used in constructors. -

-
Loader.add_implicit_resolver(tag, regexp, first) # Loader.add_implicit_resolver is a class method.
-Loader.add_path_resolver(tag, path, kind) # Loader.add_path_resolver is a class method.
-

-Loader.add_implicit_resolver(tag, regexp, first): see add_implicit_resolver. -

-

-Loader.add_path_resolver(tag, path, kind): see add_path_resolver. -

-

Dumper

-
Dumper(stream,
-    default_style=None,
-    default_flow_style=None,
-    canonical=None,
-    indent=None,
-    width=None,
-    allow_unicode=None,
-    line_break=None,
-    encoding=None,
-    explicit_start=None,
-    explicit_end=None,
-    version=None,
-    tags=None)
-SafeDumper(stream, ...)
-BaseDumper(stream, ...)
-
-# The following classes are available only if you build LibYAML bindings.
-CDumper(stream, ...)
-CSafeDumper(stream, ...)
-CBaseDumper(stream, ...)
-

-Dumper(stream) is the most common of the above classes and should be used in most cases. -stream is an output YAML stream. It can be an open file or an open Unicode file. -

-

-Dumper supports all predefined tags and may represent an arbitrary Python object. Therefore -it may produce a document that cannot be loaded by other YAML processors. By default, the functions -emit, serialize, dump, and others use Dumper. -

-

-SafeDumper(stream) produces only standard YAML tags and thus cannot represent class instances and -probably more compatible with other YAML processors. The functions safe_dump and safe_dump_all -use SafeDumper to produce a YAML document. -

-

-BaseDumper(stream) does not support any tags and is useful only for subclassing. -

-

-CDumper, CSafeDumper, CBaseDumper are versions of the above classes written in C -using the LibYAML library. -

-
Dumper.emit(event)
-

-Dumper.emit(event) serializes the given event and write it to the output stream. -

-
Dumper.open()
-Dumper.serialize(node)
-Dumper.close()
-

-Dumper.open() emits StreamStartEvent. -

-

-Dumper.serialize(node) serializes the given representation graph into the output stream. -

-

-Dumper.close() emits StreamEndEvent. -

-
Dumper.represent(data)
-
-Dumper.add_representer(data_type, representer) # Dumper.add_representer is a class method.
-Dumper.add_multi_representer(base_data_type, multi_representer) # Dumper.add_multi_representer is a class method.
-
-Dumper.represent_scalar(tag, value, style=None)
-Dumper.represent_sequence(tag, value, flow_style=None)
-Dumper.represent_mapping(tag, value, flow_style=None)
-

-Dumper.represent(data) serializes the given Python object to the output YAML stream. -

-

-Dumper.add_representer(data_type, representer): see add_representer. -

-

-Dumper.add_multi_representer(base_data_type, multi_representer): see add_multi_representer. -

-

-Dumper.represent_scalar(tag, value, style=None) returns a scalar node with the given tag, value, and style. -This function is intended to be used in representers. -

-

-Dumper.represent_sequence(tag, sequence, flow_style=None) return a sequence node with the given tag -and subnodes generated from the items of the given sequence. -

-

-Dumper.represent_mapping(tag, mapping, flow_style=None) return a mapping node with the given tag -and subnodes generated from the keys and values of the given mapping. -

-
Dumper.add_implicit_resolver(tag, regexp, first) # Dumper.add_implicit_resolver is a class method.
-Dumper.add_path_resolver(tag, path, kind) # Dumper.add_path_resolver is a class method.
-

-Dumper.add_implicit_resolver(tag, regexp, first): see add_implicit_resolver. -

-

-Dumper.add_path_resolver(tag, path, kind): see add_path_resolver. -

-

YAMLObject

-
class MyYAMLObject(YAMLObject):
-    yaml_loader = Loader
-    yaml_dumper = Dumper
-
-    yaml_tag = u'...'
-    yaml_flow_style = ...
-
-    @classmethod
-    def from_yaml(cls, loader, node):
-        # ...
-        return data
-
-    @classmethod
-    def to_yaml(cls, dumper, data):
-        # ...
-        return node
-

-Subclassing YAMLObject is an easy way to define tags, constructors, and representers -for your classes. You only need to override the yaml_tag attribute. If you want -to define your custom constructor and representer, redefine the from_yaml and to_yaml method -correspondingly. -

-

Deviations from the specification

-

-need to update this section -

-
  • rules for tabs in YAML are confusing. We are close, but not there yet. -Perhaps both the spec and the parser should be fixed. Anyway, the best -rule for tabs in YAML is to not use them at all. -
  • Byte order mark. The initial BOM is stripped, but BOMs inside the stream -are considered as parts of the content. It can be fixed, but it's not -really important now. -
  • Empty plain scalars are not allowed if alias or tag is specified. This -is done to prevent anomalities like [ !tag, value], which can be -interpreted both as [ !<!tag,> value ] and [ !<!tag> "", "value" ]. -The spec should be fixed. -
  • Indentation of flow collections. The spec requires them to be indented -more than their block parent node. Unfortunately this rule renders many intuitively -correct constructs invalid, for instance, -
    block: {
    -} # this is indentation violation according to the spec.
    -
  • ':' is not allowed for plain scalars in the flow mode. {1:2} is -interpreted as { 1 : 2 }. -
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
- - - - - - \ No newline at end of file diff --git a/pyyaml/PyYAMLDocumentation_files/jquery.js b/pyyaml/PyYAMLDocumentation_files/jquery.js deleted file mode 100644 index 9263574..0000000 --- a/pyyaml/PyYAMLDocumentation_files/jquery.js +++ /dev/null @@ -1,4376 +0,0 @@ -/*! - * jQuery JavaScript Library v1.3.2 - * http://jquery.com/ - * - * Copyright (c) 2009 John Resig - * Dual licensed under the MIT and GPL licenses. - * http://docs.jquery.com/License - * - * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009) - * Revision: 6246 - */ -(function(){ - -var - // Will speed up references to window, and allows munging its name. - window = this, - // Will speed up references to undefined, and allows munging its name. - undefined, - // Map over jQuery in case of overwrite - _jQuery = window.jQuery, - // Map over the $ in case of overwrite - _$ = window.$, - - jQuery = window.jQuery = window.$ = function( selector, context ) { - // The jQuery object is actually just the init constructor 'enhanced' - return new jQuery.fn.init( selector, context ); - }, - - // A simple way to check for HTML strings or ID strings - // (both of which we optimize for) - quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/, - // Is it a simple selector - isSimple = /^.[^:#\[\.,]*$/; - -jQuery.fn = jQuery.prototype = { - init: function( selector, context ) { - // Make sure that a selection was provided - selector = selector || document; - - // Handle $(DOMElement) - if ( selector.nodeType ) { - this[0] = selector; - this.length = 1; - this.context = selector; - return this; - } - // Handle HTML strings - if ( typeof selector === "string" ) { - // Are we dealing with HTML string or an ID? - var match = quickExpr.exec( selector ); - - // Verify a match, and that no context was specified for #id - if ( match && (match[1] || !context) ) { - - // HANDLE: $(html) -> $(array) - if ( match[1] ) - selector = jQuery.clean( [ match[1] ], context ); - - // HANDLE: $("#id") - else { - var elem = document.getElementById( match[3] ); - - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem && elem.id != match[3] ) - return jQuery().find( selector ); - - // Otherwise, we inject the element directly into the jQuery object - var ret = jQuery( elem || [] ); - ret.context = document; - ret.selector = selector; - return ret; - } - - // HANDLE: $(expr, [context]) - // (which is just equivalent to: $(content).find(expr) - } else - return jQuery( context ).find( selector ); - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( jQuery.isFunction( selector ) ) - return jQuery( document ).ready( selector ); - - // Make sure that old selector state is passed along - if ( selector.selector && selector.context ) { - this.selector = selector.selector; - this.context = selector.context; - } - - return this.setArray(jQuery.isArray( selector ) ? - selector : - jQuery.makeArray(selector)); - }, - - // Start with an empty selector - selector: "", - - // The current version of jQuery being used - jquery: "1.3.2", - - // The number of elements contained in the matched element set - size: function() { - return this.length; - }, - - // Get the Nth element in the matched element set OR - // Get the whole matched element set as a clean array - get: function( num ) { - return num === undefined ? - - // Return a 'clean' array - Array.prototype.slice.call( this ) : - - // Return just the object - this[ num ]; - }, - - // Take an array of elements and push it onto the stack - // (returning the new matched element set) - pushStack: function( elems, name, selector ) { - // Build a new jQuery matched element set - var ret = jQuery( elems ); - - // Add the old object onto the stack (as a reference) - ret.prevObject = this; - - ret.context = this.context; - - if ( name === "find" ) - ret.selector = this.selector + (this.selector ? " " : "") + selector; - else if ( name ) - ret.selector = this.selector + "." + name + "(" + selector + ")"; - - // Return the newly-formed element set - return ret; - }, - - // Force the current matched set of elements to become - // the specified array of elements (destroying the stack in the process) - // You should use pushStack() in order to do this, but maintain the stack - setArray: function( elems ) { - // Resetting the length to 0, then using the native Array push - // is a super-fast way to populate an object with array-like properties - this.length = 0; - Array.prototype.push.apply( this, elems ); - - return this; - }, - - // Execute a callback for every element in the matched set. - // (You can seed the arguments with an array of args, but this is - // only used internally.) - each: function( callback, args ) { - return jQuery.each( this, callback, args ); - }, - - // Determine the position of an element within - // the matched set of elements - index: function( elem ) { - // Locate the position of the desired element - return jQuery.inArray( - // If it receives a jQuery object, the first element is used - elem && elem.jquery ? elem[0] : elem - , this ); - }, - - attr: function( name, value, type ) { - var options = name; - - // Look for the case where we're accessing a style value - if ( typeof name === "string" ) - if ( value === undefined ) - return this[0] && jQuery[ type || "attr" ]( this[0], name ); - - else { - options = {}; - options[ name ] = value; - } - - // Check to see if we're setting style values - return this.each(function(i){ - // Set all the styles - for ( name in options ) - jQuery.attr( - type ? - this.style : - this, - name, jQuery.prop( this, options[ name ], type, i, name ) - ); - }); - }, - - css: function( key, value ) { - // ignore negative width and height values - if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) - value = undefined; - return this.attr( key, value, "curCSS" ); - }, - - text: function( text ) { - if ( typeof text !== "object" && text != null ) - return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); - - var ret = ""; - - jQuery.each( text || this, function(){ - jQuery.each( this.childNodes, function(){ - if ( this.nodeType != 8 ) - ret += this.nodeType != 1 ? - this.nodeValue : - jQuery.fn.text( [ this ] ); - }); - }); - - return ret; - }, - - wrapAll: function( html ) { - if ( this[0] ) { - // The elements to wrap the target around - var wrap = jQuery( html, this[0].ownerDocument ).clone(); - - if ( this[0].parentNode ) - wrap.insertBefore( this[0] ); - - wrap.map(function(){ - var elem = this; - - while ( elem.firstChild ) - elem = elem.firstChild; - - return elem; - }).append(this); - } - - return this; - }, - - wrapInner: function( html ) { - return this.each(function(){ - jQuery( this ).contents().wrapAll( html ); - }); - }, - - wrap: function( html ) { - return this.each(function(){ - jQuery( this ).wrapAll( html ); - }); - }, - - append: function() { - return this.domManip(arguments, true, function(elem){ - if (this.nodeType == 1) - this.appendChild( elem ); - }); - }, - - prepend: function() { - return this.domManip(arguments, true, function(elem){ - if (this.nodeType == 1) - this.insertBefore( elem, this.firstChild ); - }); - }, - - before: function() { - return this.domManip(arguments, false, function(elem){ - this.parentNode.insertBefore( elem, this ); - }); - }, - - after: function() { - return this.domManip(arguments, false, function(elem){ - this.parentNode.insertBefore( elem, this.nextSibling ); - }); - }, - - end: function() { - return this.prevObject || jQuery( [] ); - }, - - // For internal use only. - // Behaves like an Array's method, not like a jQuery method. - push: [].push, - sort: [].sort, - splice: [].splice, - - find: function( selector ) { - if ( this.length === 1 ) { - var ret = this.pushStack( [], "find", selector ); - ret.length = 0; - jQuery.find( selector, this[0], ret ); - return ret; - } else { - return this.pushStack( jQuery.unique(jQuery.map(this, function(elem){ - return jQuery.find( selector, elem ); - })), "find", selector ); - } - }, - - clone: function( events ) { - // Do the clone - var ret = this.map(function(){ - if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { - // IE copies events bound via attachEvent when - // using cloneNode. Calling detachEvent on the - // clone will also remove the events from the orignal - // In order to get around this, we use innerHTML. - // Unfortunately, this means some modifications to - // attributes in IE that are actually only stored - // as properties will not be copied (such as the - // the name attribute on an input). - var html = this.outerHTML; - if ( !html ) { - var div = this.ownerDocument.createElement("div"); - div.appendChild( this.cloneNode(true) ); - html = div.innerHTML; - } - - return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g, "").replace(/^\s*/, "")])[0]; - } else - return this.cloneNode(true); - }); - - // Copy the events from the original to the clone - if ( events === true ) { - var orig = this.find("*").andSelf(), i = 0; - - ret.find("*").andSelf().each(function(){ - if ( this.nodeName !== orig[i].nodeName ) - return; - - var events = jQuery.data( orig[i], "events" ); - - for ( var type in events ) { - for ( var handler in events[ type ] ) { - jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); - } - } - - i++; - }); - } - - // Return the cloned set - return ret; - }, - - filter: function( selector ) { - return this.pushStack( - jQuery.isFunction( selector ) && - jQuery.grep(this, function(elem, i){ - return selector.call( elem, i ); - }) || - - jQuery.multiFilter( selector, jQuery.grep(this, function(elem){ - return elem.nodeType === 1; - }) ), "filter", selector ); - }, - - closest: function( selector ) { - var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, - closer = 0; - - return this.map(function(){ - var cur = this; - while ( cur && cur.ownerDocument ) { - if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { - jQuery.data(cur, "closest", closer); - return cur; - } - cur = cur.parentNode; - closer++; - } - }); - }, - - not: function( selector ) { - if ( typeof selector === "string" ) - // test special case where just one selector is passed in - if ( isSimple.test( selector ) ) - return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector ); - else - selector = jQuery.multiFilter( selector, this ); - - var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; - return this.filter(function() { - return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; - }); - }, - - add: function( selector ) { - return this.pushStack( jQuery.unique( jQuery.merge( - this.get(), - typeof selector === "string" ? - jQuery( selector ) : - jQuery.makeArray( selector ) - ))); - }, - - is: function( selector ) { - return !!selector && jQuery.multiFilter( selector, this ).length > 0; - }, - - hasClass: function( selector ) { - return !!selector && this.is( "." + selector ); - }, - - val: function( value ) { - if ( value === undefined ) { - var elem = this[0]; - - if ( elem ) { - if( jQuery.nodeName( elem, 'option' ) ) - return (elem.attributes.value || {}).specified ? elem.value : elem.text; - - // We need to handle select boxes special - if ( jQuery.nodeName( elem, "select" ) ) { - var index = elem.selectedIndex, - values = [], - options = elem.options, - one = elem.type == "select-one"; - - // Nothing was selected - if ( index < 0 ) - return null; - - // Loop through all the selected options - for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { - var option = options[ i ]; - - if ( option.selected ) { - // Get the specifc value for the option - value = jQuery(option).val(); - - // We don't need an array for one selects - if ( one ) - return value; - - // Multi-Selects return an array - values.push( value ); - } - } - - return values; - } - - // Everything else, we just grab the value - return (elem.value || "").replace(/\r/g, ""); - - } - - return undefined; - } - - if ( typeof value === "number" ) - value += ''; - - return this.each(function(){ - if ( this.nodeType != 1 ) - return; - - if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) ) - this.checked = (jQuery.inArray(this.value, value) >= 0 || - jQuery.inArray(this.name, value) >= 0); - - else if ( jQuery.nodeName( this, "select" ) ) { - var values = jQuery.makeArray(value); - - jQuery( "option", this ).each(function(){ - this.selected = (jQuery.inArray( this.value, values ) >= 0 || - jQuery.inArray( this.text, values ) >= 0); - }); - - if ( !values.length ) - this.selectedIndex = -1; - - } else - this.value = value; - }); - }, - - html: function( value ) { - return value === undefined ? - (this[0] ? - this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") : - null) : - this.empty().append( value ); - }, - - replaceWith: function( value ) { - return this.after( value ).remove(); - }, - - eq: function( i ) { - return this.slice( i, +i + 1 ); - }, - - slice: function() { - return this.pushStack( Array.prototype.slice.apply( this, arguments ), - "slice", Array.prototype.slice.call(arguments).join(",") ); - }, - - map: function( callback ) { - return this.pushStack( jQuery.map(this, function(elem, i){ - return callback.call( elem, i, elem ); - })); - }, - - andSelf: function() { - return this.add( this.prevObject ); - }, - - domManip: function( args, table, callback ) { - if ( this[0] ) { - var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(), - scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ), - first = fragment.firstChild; - - if ( first ) - for ( var i = 0, l = this.length; i < l; i++ ) - callback.call( root(this[i], first), this.length > 1 || i > 0 ? - fragment.cloneNode(true) : fragment ); - - if ( scripts ) - jQuery.each( scripts, evalScript ); - } - - return this; - - function root( elem, cur ) { - return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ? - (elem.getElementsByTagName("tbody")[0] || - elem.appendChild(elem.ownerDocument.createElement("tbody"))) : - elem; - } - } -}; - -// Give the init function the jQuery prototype for later instantiation -jQuery.fn.init.prototype = jQuery.fn; - -function evalScript( i, elem ) { - if ( elem.src ) - jQuery.ajax({ - url: elem.src, - async: false, - dataType: "script" - }); - - else - jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); - - if ( elem.parentNode ) - elem.parentNode.removeChild( elem ); -} - -function now(){ - return +new Date; -} - -jQuery.extend = jQuery.fn.extend = function() { - // copy reference to target object - var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; - - // Handle a deep copy situation - if ( typeof target === "boolean" ) { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - - // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !jQuery.isFunction(target) ) - target = {}; - - // extend jQuery itself if only one argument is passed - if ( length == i ) { - target = this; - --i; - } - - for ( ; i < length; i++ ) - // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) != null ) - // Extend the base object - for ( var name in options ) { - var src = target[ name ], copy = options[ name ]; - - // Prevent never-ending loop - if ( target === copy ) - continue; - - // Recurse if we're merging object values - if ( deep && copy && typeof copy === "object" && !copy.nodeType ) - target[ name ] = jQuery.extend( deep, - // Never move original objects, clone them - src || ( copy.length != null ? [ ] : { } ) - , copy ); - - // Don't bring in undefined values - else if ( copy !== undefined ) - target[ name ] = copy; - - } - - // Return the modified object - return target; -}; - -// exclude the following css properties to add px -var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, - // cache defaultView - defaultView = document.defaultView || {}, - toString = Object.prototype.toString; - -jQuery.extend({ - noConflict: function( deep ) { - window.$ = _$; - - if ( deep ) - window.jQuery = _jQuery; - - return jQuery; - }, - - // See test/unit/core.js for details concerning isFunction. - // Since version 1.3, DOM methods and functions like alert - // aren't supported. They return false on IE (#2968). - isFunction: function( obj ) { - return toString.call(obj) === "[object Function]"; - }, - - isArray: function( obj ) { - return toString.call(obj) === "[object Array]"; - }, - - // check if an element is in a (or is an) XML document - isXMLDoc: function( elem ) { - return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || - !!elem.ownerDocument && jQuery.isXMLDoc( elem.ownerDocument ); - }, - - // Evalulates a script in a global context - globalEval: function( data ) { - if ( data && /\S/.test(data) ) { - // Inspired by code by Andrea Giammarchi - // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html - var head = document.getElementsByTagName("head")[0] || document.documentElement, - script = document.createElement("script"); - - script.type = "text/javascript"; - if ( jQuery.support.scriptEval ) - script.appendChild( document.createTextNode( data ) ); - else - script.text = data; - - // Use insertBefore instead of appendChild to circumvent an IE6 bug. - // This arises when a base node is used (#2709). - head.insertBefore( script, head.firstChild ); - head.removeChild( script ); - } - }, - - nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); - }, - - // args is for internal usage only - each: function( object, callback, args ) { - var name, i = 0, length = object.length; - - if ( args ) { - if ( length === undefined ) { - for ( name in object ) - if ( callback.apply( object[ name ], args ) === false ) - break; - } else - for ( ; i < length; ) - if ( callback.apply( object[ i++ ], args ) === false ) - break; - - // A special, fast, case for the most common use of each - } else { - if ( length === undefined ) { - for ( name in object ) - if ( callback.call( object[ name ], name, object[ name ] ) === false ) - break; - } else - for ( var value = object[0]; - i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} - } - - return object; - }, - - prop: function( elem, value, type, i, name ) { - // Handle executable functions - if ( jQuery.isFunction( value ) ) - value = value.call( elem, i ); - - // Handle passing in a number to a CSS property - return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ? - value + "px" : - value; - }, - - className: { - // internal only, use addClass("class") - add: function( elem, classNames ) { - jQuery.each((classNames || "").split(/\s+/), function(i, className){ - if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) - elem.className += (elem.className ? " " : "") + className; - }); - }, - - // internal only, use removeClass("class") - remove: function( elem, classNames ) { - if (elem.nodeType == 1) - elem.className = classNames !== undefined ? - jQuery.grep(elem.className.split(/\s+/), function(className){ - return !jQuery.className.has( classNames, className ); - }).join(" ") : - ""; - }, - - // internal only, use hasClass("class") - has: function( elem, className ) { - return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; - } - }, - - // A method for quickly swapping in/out CSS properties to get correct calculations - swap: function( elem, options, callback ) { - var old = {}; - // Remember the old values, and insert the new ones - for ( var name in options ) { - old[ name ] = elem.style[ name ]; - elem.style[ name ] = options[ name ]; - } - - callback.call( elem ); - - // Revert the old values - for ( var name in options ) - elem.style[ name ] = old[ name ]; - }, - - css: function( elem, name, force, extra ) { - if ( name == "width" || name == "height" ) { - var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; - - function getWH() { - val = name == "width" ? elem.offsetWidth : elem.offsetHeight; - - if ( extra === "border" ) - return; - - jQuery.each( which, function() { - if ( !extra ) - val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; - if ( extra === "margin" ) - val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; - else - val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; - }); - } - - if ( elem.offsetWidth !== 0 ) - getWH(); - else - jQuery.swap( elem, props, getWH ); - - return Math.max(0, Math.round(val)); - } - - return jQuery.curCSS( elem, name, force ); - }, - - curCSS: function( elem, name, force ) { - var ret, style = elem.style; - - // We need to handle opacity special in IE - if ( name == "opacity" && !jQuery.support.opacity ) { - ret = jQuery.attr( style, "opacity" ); - - return ret == "" ? - "1" : - ret; - } - - // Make sure we're using the right name for getting the float value - if ( name.match( /float/i ) ) - name = styleFloat; - - if ( !force && style && style[ name ] ) - ret = style[ name ]; - - else if ( defaultView.getComputedStyle ) { - - // Only "float" is needed here - if ( name.match( /float/i ) ) - name = "float"; - - name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); - - var computedStyle = defaultView.getComputedStyle( elem, null ); - - if ( computedStyle ) - ret = computedStyle.getPropertyValue( name ); - - // We should always get a number back from opacity - if ( name == "opacity" && ret == "" ) - ret = "1"; - - } else if ( elem.currentStyle ) { - var camelCase = name.replace(/\-(\w)/g, function(all, letter){ - return letter.toUpperCase(); - }); - - ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; - - // From the awesome hack by Dean Edwards - // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 - - // If we're not dealing with a regular pixel number - // but a number that has a weird ending, we need to convert it to pixels - if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { - // Remember the original values - var left = style.left, rsLeft = elem.runtimeStyle.left; - - // Put in the new values to get a computed value out - elem.runtimeStyle.left = elem.currentStyle.left; - style.left = ret || 0; - ret = style.pixelLeft + "px"; - - // Revert the changed values - style.left = left; - elem.runtimeStyle.left = rsLeft; - } - } - - return ret; - }, - - clean: function( elems, context, fragment ) { - context = context || document; - - // !context.createElement fails in IE with an error but returns typeof 'object' - if ( typeof context.createElement === "undefined" ) - context = context.ownerDocument || context[0] && context[0].ownerDocument || document; - - // If a single string is passed in and it's a single tag - // just do a createElement and skip the rest - if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) { - var match = /^<(\w+)\s*\/?>$/.exec(elems[0]); - if ( match ) - return [ context.createElement( match[1] ) ]; - } - - var ret = [], scripts = [], div = context.createElement("div"); - - jQuery.each(elems, function(i, elem){ - if ( typeof elem === "number" ) - elem += ''; - - if ( !elem ) - return; - - // Convert html string into DOM nodes - if ( typeof elem === "string" ) { - // Fix "XHTML"-style tags in all browsers - elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ - return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? - all : - front + ">"; - }); - - // Trim whitespace, otherwise indexOf won't work as expected - var tags = elem.replace(/^\s+/, "").substring(0, 10).toLowerCase(); - - var wrap = - // option or optgroup - !tags.indexOf("", "" ] || - - !tags.indexOf("", "" ] || - - tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && - [ 1, "", "
" ] || - - !tags.indexOf("", "" ] || - - // matched above - (!tags.indexOf("", "" ] || - - !tags.indexOf("", "" ] || - - // IE can't serialize and - - - - - - - -
-
-
- -

YAMLish

-
-

From Test Anything Protocol

-
-
Jump to: navigation, search
-

YAMLish is a small subset of YAML that TAP producers may use to embed machine readable information in TAP diagnostics. See TAP diagnostic syntax for information about how YAMLish embeds in TAP. -

-

Contents

- -
-

[edit] Objectives

-

The main objectives for YAMLish are -

-
  • small - the Perl reader is around 124 lines, 258 lines for the parser -
  • portable - it should be reasonably easy to implement YAMLish in any language -
  • able to encode arbitrary data structures -
  • verifiable - it should be relatively to easy to test that a YAMLish implementation conforms -
  • JSON compatible - YAMLish should be a super-set of JSON to -allow TAP producers to make use of JSON libraries (objective not met) -
-

[edit] Syntax

-

To avoid the burden of distributing a complete YAML parser with a TAP - producer or consumer YAMLish confines itself to a subset of YAML -syntax. -

These examples demonstrates the supported syntax. -

All YAMLish documents must begin with '---' and end with a line containing '...'. -

-
   --- Simple scalar
-   ...
-
-

Unprintable characters are represented using standard escapes in double quoted strings. -

-
   --- "\t\x01\x02\n"
-   ...
-
-

Array and hashes are represented thusly -

-
   ---
-     - "This"
-     - "is"
-     - "an"
-     - "array"
-   ...
-
-
   ---
-     This: is
-     a: hash
-   ...
-
-

Hash keys may be double quoted strings and may contain unprintable characters -

-
   ---
-     "\t\x00": "My key is <tab><nul>"
-     "Now is the time": "t'was ever thus"
-   ...
-   
-
-

Structures may nest arbitrarily -

-
   ---
-     -
-       name: 'Hash one'
-       value: 1
-     -
-       name: 'Hash two'
-       value: 2
-   ...
-
-

Undef is a tilde -

-
   --- ~
-   ...
-
-

[edit] Root Namespace

-

When used with TAP the root element of an embedded YAMLish diagnostic is a hash containing keys from this set: -

-
message -
A textual message giving more detail about the failure (or success) -
severity -
The severity of the problem. -
source -
A uri describing the source of the TAP. This can be a file URL. See "file" for a special case. -
datetime -
the time the test was executed, helping test runners do -interesting things like run tests in order of most-recently-failed. -ISO8601 or HTTP date format. -
file -
A filename representing the TAP source, really a special case -of "source". Not possible for all TAP sources, but I really don't want -everyone to have to use file URIs. -
line -
The line number of the TAP source from which this test was produced. Not possible for all TAP sources. -
name -
Name of this test, if any. -
extensions -
A place to put any non-standard keys without worrying out conflicting with future ones -
actual -
For comparison tests, what you got. -
expected -
For comparison tests, what you expected. -
display -
Suggested text to display representing this failure -
dump -
A hash of variables to be pretty-printed by the harness -
error -
An error or exception object -
backtrace -
A stack backtrace in the case of an error or exception -
-

(please feel free to add to this list - it's provisional at the moment) -

-

[edit] Implementations

-

Because YAMLish is a subset of YAML there are already a number of -parsers in a number of languages that accept it. It's also quite likely -that existing YAML producers can be coerced into producing YAMLish -compliant YAML. Please be careful though to ensure that your YAMLish -producer does in fact conform to the subset defined here. Just because -your YAML happens to work with a particular test harness doesn't mean -that it's valid YAMLish. -

YAMLish is based on the subset of YAML supported by Adam Kennedy's YAML::Tiny - Perl module. YAML::Tiny doesn't support quoted hash keys - which we -need so that we can safely round-trip arbitrary data structures - so -YAMLish extends Adam's de-facto subset to include these. -

If your concern is only to produce well formed TAP (rather than -parsing it) then you should find that it's possible to implement a -YAMLish writer in a couple of hundred lines of code. -

-

[edit] Perl

-
  • TAP::Parser - implements YAMLish support. You'll need the version from the subversion - repository though; YAMLish support hasn't yet made it to CPAN. -
  • Data::YAML is essentially the YAMLish engine from TAP::Parser packaged as a standalone module -
-

[edit] PHP

-
  • YAMLishWriter is a simple PHP implementation of a YAMLish encoder -
-

If you have a YAMLish implementation please list it here. -

-

[edit] Q&A

-

[edit] Why YAML?

-

TAP diagnostics require a way to represent data structions in any -language in a human and machine readable form. It would be nice if we -didn't have to write our own format. YAML, like TAP, is designed to be -both human and machine readable as well as language independent. YAML portable generators and parsers already exist in many languages. portable generators YAML has already solved the hard problems facing a data serialization format (like character sets). -

-

[edit] Why not JSON?

-

JSON was considered, and it has some of the characteristics of YAML, but it was ultimately rejected for several reasons. -

JSON is, effectively, a subset of YAML. If your producer emits JSON then a YAML parser will read it. The inverse is not true. -

JSON is more verbose, less human readable, requiring more quoting. For example: -

-
 # YAML
- ---
- got:      this
- expected: that
- ...
- 
- # JSON
- {
-   "got":      "this"
-   "expected": "that"
- }
-
-

JSON lacks a WYSIWYG multi-line scalar value format. YAML has -several. | allows the exact text to be presented, newlines and all. -> "soft wraps" text to prevent long lines from spilling across the -screen. -

-
 # YAML
- ---
- got: >
-    When in the course of human events,
-    blah blah blah
- expected: >
-    When, in the course of human events,
-    it becomes necessary for one people to
-    dissolve the political bonds which have 
-    connected them with another...
- ...
-
-
 # JSON
- {
-   "got":      "When in the course of human events, blah blah blah"
-   "expected": "When, in the course of human events, it becomes necessary for one people to dissolve the political bonds which have connected them with another..."
- }
-
-

[edit] Why the --- and ... markers?

-

With the diagnostics indented to indicate they're diagnostics, why -the --- and ... markers? TAP producers tend to spit a lot of junk to -STDOUT, either explicitly as poorly written comments or accidentally -because the thing they're testing prints to STDOUT. We don't want just -any old indented text to be parsed, so we put the --- and ... markers -around it. The --- is there to indicate the start of a block. The ... -is there to indicate it has ended so the parser does not have to wait -for the next test line (which could take a while) to know there's no -more diagnostics for the previous test forthcoming. -

- - - -
-
-
-
-
-
-
Views
-
- -
-
-
-
Personal tools
- -
- - - - - -
-
- - - - -
- - \ No newline at end of file diff --git a/pyyaml/YAMLish_files/commonPrint.css b/pyyaml/YAMLish_files/commonPrint.css deleted file mode 100644 index 4fddafa..0000000 --- a/pyyaml/YAMLish_files/commonPrint.css +++ /dev/null @@ -1,290 +0,0 @@ -/* -** MediaWiki Print style sheet for CSS2-capable browsers. -** Copyright Gabriel Wicke, http://www.aulinx.de/ -** -** Derived from the plone (http://plone.org/) styles -** Copyright Alexander Limi -*/ - -/* Thanks to A List Apart (http://alistapart.com/) for useful extras */ -a.stub, -a.new{ color:#ba0000; text-decoration:none; } - -#toc { - /*border:1px solid #2f6fab;*/ - border:1px solid #aaaaaa; - background-color:#f9f9f9; - padding:5px; -} -.tocindent { - margin-left: 2em; -} -.tocline { - margin-bottom: 0px; -} - -/* images */ -div.floatright { - float: right; - clear: right; - margin: 0; - position:relative; - border: 0.5em solid White; - border-width: 0.5em 0 0.8em 1.4em; -} -div.floatright p { font-style: italic;} -div.floatleft { - float: left; - margin: 0.3em 0.5em 0.5em 0; - position:relative; - border: 0.5em solid White; - border-width: 0.5em 1.4em 0.8em 0; -} -div.floatleft p { font-style: italic; } -/* thumbnails */ -div.thumb { - margin-bottom: 0.5em; - border-style: solid; border-color: White; - width: auto; - overflow: hidden; -} -div.thumb div { - border:1px solid #cccccc; - padding: 3px !important; - background-color:#f9f9f9; - font-size: 94%; - text-align: center; -} -div.thumb div a img { - border:1px solid #cccccc; -} -div.thumb div div.thumbcaption { - border: none; - padding: 0.3em 0 0.1em 0; -} -div.magnify { display: none; } -div.tright { - float: right; - clear: right; - border-width: 0.5em 0 0.8em 1.4em; -} -div.tleft { - float: left; - margin-right:0.5em; - border-width: 0.5em 1.4em 0.8em 0; -} - -/* table standards */ -table.rimage { - float:right; - width:1pt; - position:relative; - margin-left:1em; - margin-bottom:1em; - text-align:center; -} - -body { - background: White; - /*font-size: 11pt !important;*/ - color: Black; - margin: 0; - padding: 0; -} - -.noprint, -div#jump-to-nav, -div.top, -div#column-one, -#colophon, -.editsection, -.toctoggle, -.tochidden, -div#f-poweredbyico, -div#f-copyrightico, -li#viewcount, -li#about, -li#disclaimer, -li#privacy { - /* Hides all the elements irrelevant for printing */ - display: none; -} - -ul { - list-style-type: square; -} - -#content { - background: none; - border: none ! important; - padding: 0 ! important; - margin: 0 ! important; -} -#footer { - background : white; - color : black; - border-top: 1px solid black; -} - -h1, h2, h3, h4, h5, h6 -{ - font-weight: bold; -} - -p, .documentDescription { - margin: 1em 0 ! important; - line-height: 1.2em; -} - -.tocindent p { - margin: 0 0 0 0 ! important; -} - -pre { - border: 1pt dashed black; - white-space: pre; - font-size: 8pt; - overflow: auto; - padding: 1em 0; - background : white; - color : black; -} - -table.listing, -table.listing td { - border: 1pt solid black; - border-collapse: collapse; -} - -a { - color: Black !important; - background: none !important; - padding: 0 !important; -} - -a:link, a:visited { - color: #520; - background: transparent; - text-decoration: underline; -} - -#content a.external.text:after, #content a.external.autonumber:after { - /* Expand URLs for printing */ - content: " (" attr(href) ") "; -} - -#globalWrapper { - width: 100% !important; - min-width: 0 !important; -} - -#content { - background : white; - color : black; -} - -#column-content { - margin: 0 !important; -} - -#column-content #content { - padding: 1em; - margin: 0 !important; -} -/* MSIE/Win doesn't understand 'inherit' */ -a, a.external, a.new, a.stub { - color: black ! important; - text-decoration: none ! important; -} - -/* Continue ... */ -a, a.external, a.new, a.stub { - color: inherit ! important; - text-decoration: inherit ! important; -} - -img { border: none; } -img.tex { vertical-align: middle; } -span.texhtml { font-family: serif; } - -div.townBox { - position:relative; - float:right; - background:White; - margin-left:1em; - border: 1px solid gray; - padding:0.3em; - width: 200px; - overflow: hidden; - clear: right; -} -div.townBox dl { - padding: 0; - margin: 0 0 0.3em 0; - font-size: 96%; -} -div.townBox dl dt { - background: none; - margin: 0.4em 0 0 0; -} -div.townBox dl dd { - margin: 0.1em 0 0 1.1em; - background-color: #f3f3f3; -} - -#siteNotice { display: none; } - -table.gallery { - border: 1px solid #cccccc; - margin: 2px; - padding: 2px; - background-color:#ffffff; -} - -table.gallery tr { - vertical-align:top; -} - -div.gallerybox { - border: 1px solid #cccccc; - margin: 2px; - background-color:#f9f9f9; - width: 150px; -} - -div.gallerybox div.thumb { - text-align: center; - border: 1px solid #cccccc; - margin: 2px; -} - -div.gallerytext { - font-size: 94%; - padding: 2px 4px; -} - -/* -** Diff rendering -*/ -table.diff { background:white; } -td.diff-otitle { background:#ffffff; } -td.diff-ntitle { background:#ffffff; } -td.diff-addedline { - background:#ccffcc; - font-size: smaller; - border: solid 2px black; -} -td.diff-deletedline { - background:#ffffaa; - font-size: smaller; - border: dotted 2px black; -} -td.diff-context { - background:#eeeeee; - font-size: smaller; -} -.diffchange { - color: silver; - font-weight: bold; - text-decoration: underline; -} diff --git a/pyyaml/YAMLish_files/gnu-fdl.png b/pyyaml/YAMLish_files/gnu-fdl.png deleted file mode 100644 index 1371aba..0000000 Binary files a/pyyaml/YAMLish_files/gnu-fdl.png and /dev/null differ diff --git a/pyyaml/YAMLish_files/handheld.css b/pyyaml/YAMLish_files/handheld.css deleted file mode 100644 index 754aba9..0000000 --- a/pyyaml/YAMLish_files/handheld.css +++ /dev/null @@ -1,1337 +0,0 @@ -/* -** MediaWiki 'monobook' style sheet for CSS2-capable browsers. -** Copyright Gabriel Wicke - http://wikidev.net/ -** License: GPL (http://www.gnu.org/copyleft/gpl.html) -** -** Loosely based on http://www.positioniseverything.net/ordered-floats.html by Big John -** and the Plone 2.0 styles, see http://plone.org/ (Alexander Limi,Joe Geldart & Tom Croucher, -** Michael Zeltner and Geir Bækholt) -** All you guys rock :) -*/ - -/** - * Stylesheet for handhelds. All rules not marked media-specific are shared - * with main.css and should be updated in tandem. The rules can't be in the - * same file because old browsers like IE5 won't obey @media rules. - * - * Rules that are handheld-specific are given @media rules in case old browsers - * don't recognize the media attribute and load this file anyway. - */ - -#content { - background: white; - color: black; - border: 1px solid #aaa; - border-right: none; - line-height: 1.5em; -} -/* the left column width is specified in class .portlet */ - -/* Font size: -** We take advantage of keyword scaling- browsers won't go below 9px -** More at http://www.w3.org/2003/07/30-font-size -** http://style.cleverchimp.com/font_size_intervals/altintervals.html -*/ - -body { - font: x-small sans-serif; - background: #f9f9f9 url(headbg.jpg) 0 0 no-repeat; - color: black; - margin: 0; - padding: 0; -} - -/* scale back up to a sane default */ -#globalWrapper { - font-size: 127%; - width: 100%; - margin: 0; - padding: 0; -} -.visualClear { - clear: both; -} - -/* general styles */ - -table { - font-size: 100%; - color: black; - /* we don't want the bottom borders of

s to be visible through - floated tables */ - background-color: white; -} -a { - text-decoration: none; - color: #002bb8; - background: none; -} -a:visited { - color: #5a3696; -} -a:active { - color: #faa700; -} -a:hover { - text-decoration: underline; -} -a.stub { - color: #772233; -} -a.new, #p-personal a.new { - color: #ba0000; -} -a.new:visited, #p-personal a.new:visited { - color: #a55858; -} - -img { - border: none; - vertical-align: middle; -} -p img { - margin: 0; -} - -hr { - height: 1px; - color: #aaa; - background-color: #aaa; - border: 0; - margin: .2em 0 .2em 0; -} - -h1, h2, h3, h4, h5, h6 { - color: black; - background: none; - font-weight: normal; - margin: 0; - padding-top: .5em; - padding-bottom: .17em; - border-bottom: 1px solid #aaa; -} -h1 { font-size: 188%; } -h1 .editsection { font-size: 53%; } -h2 { font-size: 150%; } -h2 .editsection { font-size: 67%; } -h3, h4, h5, h6 { - border-bottom: none; - font-weight: bold; -} -h3 { font-size: 132%; } -h3 .editsection { font-size: 76%; font-weight: normal; } -h4 { font-size: 116%; } -h4 .editsection { font-size: 86%; font-weight: normal; } -h5 { font-size: 100%; } -h5 .editsection { font-weight: normal; } -h6 { font-size: 80%; } -h6 .editsection { font-size: 125%; font-weight: normal; } - -.editsection { - float: right; - margin-left: 5px; -} - -ul { - line-height: 1.5em; - list-style-type: square; - margin: .3em 0 0 1.5em; - padding: 0; - list-style-image: url(bullet.gif); -} -ol { - line-height: 1.5em; - margin: .3em 0 0 3.2em; - padding: 0; - list-style-image: none; -} -li { - margin-bottom: .1em; -} -dt { - font-weight: bold; - margin-bottom: .1em; -} -dl { - margin-top: .2em; - margin-bottom: .5em; -} -dd { - line-height: 1.5em; - margin-left: 2em; - margin-bottom: .1em; -} - -fieldset { - border: 1px solid #2f6fab; - margin: 1em 0 1em 0; - padding: 0 1em 1em; - line-height: 1.5em; -} -legend { - padding: .5em; - font-size: 95%; -} -form { - border: none; - margin: 0; -} - -textarea { - width: 100%; - padding: .1em; -} - -input.historysubmit { - padding: 0 .3em .3em .3em !important; - font-size: 94%; - cursor: pointer; - height: 1.7em !important; - margin-left: 1.6em; -} -select { - vertical-align: top; -} -abbr, acronym, .explain { - border-bottom: 1px dotted black; - color: black; - background: none; - cursor: help; -} -q { - font-family: Times, "Times New Roman", serif; - font-style: italic; -} -/* disabled for now -blockquote { - font-family: Times, "Times New Roman", serif; - font-style: italic; -}*/ -code { - background-color: #f9f9f9; -} -pre { - padding: 1em; - border: 1px dashed #2f6fab; - color: black; - background-color: #f9f9f9; - line-height: 1.1em; -} - -/* -** the main content area -*/ - -#contentSub, #contentSub2 { - font-size: 84%; - line-height: 1.2em; - margin: 0 0 1.4em 1em; - color: #7d7d7d; - width: auto; -} -span.subpages { - display: block; -} - -/* Some space under the headers in the content area */ -#bodyContent h1, #bodyContent h2 { - margin-bottom: .6em; -} -#bodyContent h3, #bodyContent h4, #bodyContent h5 { - margin-bottom: .3em; -} -.firstHeading { - margin-bottom: .1em; -} - -/* user notification thing */ -.usermessage { - background-color: #ffce7b; - border: 1px solid #ffa500; - color: black; - font-weight: bold; - margin: 2em 0 1em; - padding: .5em 1em; - vertical-align: middle; -} -#siteNotice { - text-align: center; - font-size: 95%; - padding: 0 .9em; -} -#siteNotice p { - margin: 0; - padding: 0; -} -.error { - color: red; - font-size: larger; -} -.errorbox, .successbox { - font-size: larger; - border: 2px solid; - padding: .5em 1em; - float: left; - margin-bottom: 2em; - color: #000; -} -.errorbox { - border-color: red; - background-color: #fff2f2; -} -.successbox { - border-color: green; - background-color: #dfd; -} -.errorbox h2, .successbox h2 { - font-size: 1em; - font-weight: bold; - display: inline; - margin: 0 .5em 0 0; - border: none; -} - -#catlinks { - border: 1px solid #aaa; - background-color: #f9f9f9; - padding: 5px; - margin-top: 1em; - clear: both; -} -/* currently unused, intended to be used by a metadata box -in the bottom-right corner of the content area */ -.documentDescription { - /* The summary text describing the document */ - font-weight: bold; - display: block; - margin: 1em 0; - line-height: 1.5em; -} -.documentByLine { - text-align: right; - font-size: 90%; - clear: both; - font-weight: normal; - color: #76797c; -} - -/* emulate center */ -.center { - width: 100%; - text-align: center; -} -*.center * { - margin-left: auto; - margin-right: auto; -} -/* small for tables and similar */ -.small, .small * { - font-size: 94%; -} -table.small { - font-size: 100%; -} - -/* -** content styles -*/ - -#toc, -.toc, -.mw-warning { - border: 1px solid #aaa; - background-color: #f9f9f9; - padding: 5px; - font-size: 95%; -} -#toc h2, -.toc h2 { - display: inline; - border: none; - padding: 0; - font-size: 100%; - font-weight: bold; -} -#toc #toctitle, -.toc #toctitle, -#toc .toctitle, -.toc .toctitle { - text-align: center; -} -#toc ul, -.toc ul { - list-style-type: none; - list-style-image: none; - margin-left: 0; - padding-left: 0; - text-align: left; -} -#toc ul ul, -.toc ul ul { - margin: 0 0 0 2em; -} -#toc .toctoggle, -.toc .toctoggle { - font-size: 94%; -} - -.mw-warning { - margin-left: 50px; - margin-right: 50px; - text-align: center; -} - -/* images */ -div.floatright, table.floatright { - clear: right; - float: right; - position: relative; - margin: 0 0 .5em .5em; - border: 0; -/* - border: .5em solid white; - border-width: .5em 0 .8em 1.4em; -*/ -} -div.floatright p { font-style: italic; } -div.floatleft, table.floatleft { - float: left; - clear: left; - position: relative; - margin: 0 .5em .5em 0; - border: 0; -/* - margin: .3em .5em .5em 0; - border: .5em solid white; - border-width: .5em 1.4em .8em 0; -*/ -} -div.floatleft p { font-style: italic; } -/* thumbnails */ -div.thumb { - margin-bottom: .5em; - border-style: solid; - border-color: white; - width: auto; -} -div.thumbinner { - border: 1px solid #ccc; - padding: 3px !important; - background-color: #f9f9f9; - font-size: 94%; - text-align: center; - overflow: hidden; -} -html .thumbimage { - border: 1px solid #ccc; -} -html .thumbcaption { - border: none; - text-align: left; - line-height: 1.4em; - padding: 3px !important; - font-size: 94%; -} -div.magnify { - float: right; - border: none !important; - background: none !important; -} -div.magnify a, div.magnify img { - display: block; - border: none !important; - background: none !important; -} -div.tright { - clear: right; - float: right; - border-width: .5em 0 .8em 1.4em; -} -div.tleft { - float: left; - clear: left; - margin-right: .5em; - border-width: .5em 1.4em .8em 0; -} - -.hiddenStructure { - display: none; - speak: none; -} -img.tex { - vertical-align: middle; -} -span.texhtml { - font-family: serif; -} - -/* -** classes for special content elements like town boxes -** intended to be referenced directly from the wiki src -*/ - -/* -** User styles -*/ -/* table standards */ -table.rimage { - float: right; - position: relative; - margin-left: 1em; - margin-bottom: 1em; - text-align: center; -} -.toccolours { - border: 1px solid #aaa; - background-color: #f9f9f9; - padding: 5px; - font-size: 95%; -} -div.townBox { - position: relative; - float: right; - background: white; - margin-left: 1em; - border: 1px solid gray; - padding: .3em; - width: 200px; - overflow: hidden; - clear: right; -} -div.townBox dl { - padding: 0; - margin: 0 0 .3em; - font-size: 96%; -} -div.townBox dl dt { - background: none; - margin: .4em 0 0; -} -div.townBox dl dd { - margin: .1em 0 0 1.1em; - background-color: #f3f3f3; -} - -/* -** edit views etc -*/ -.special li { - line-height: 1.4em; - margin: 0; - padding: 0; -} - -/* Page history styling */ -/* the auto-generated edit comments */ -.autocomment { - color: gray; -} -#pagehistory span.user { - margin-left: 1.4em; - margin-right: .4em; -} -#pagehistory span.minor { - font-weight: bold; -} -#pagehistory li { - border: 1px solid white; -} -#pagehistory li.selected { - background-color: #f9f9f9; - border: 1px dashed #aaa; -} - -/* -** Diff rendering -*/ -table.diff, td.diff-otitle, td.diff-ntitle { - background-color: white; -} -td.diff-addedline { - background: #cfc; - font-size: smaller; -} -td.diff-deletedline { - background: #ffa; - font-size: smaller; -} -td.diff-context { - background: #eee; - font-size: smaller; -} -.diffchange { - color: red; - font-weight: bold; -} - -/* -** keep the whitespace in front of the ^=, hides rule from konqueror -** this is css3, the validator doesn't like it when validating as css2 -*/ -#bodyContent a.external, -#bodyContent a[href ^="gopher://"] { - background: url(external.png) center right no-repeat; - padding-right: 13px; -} -#bodyContent a[href ^="https://"], -.link-https { - background: url(lock_icon.gif) center right no-repeat; - padding-right: 16px; -} -#bodyContent a[href ^="mailto:"], -.link-mailto { - background: url(mail_icon.gif) center right no-repeat; - padding-right: 18px; -} -#bodyContent a[href ^="news://"] { - background: url(news_icon.png) center right no-repeat; - padding-right: 18px; -} -#bodyContent a[href ^="ftp://"], -.link-ftp { - background: url(file_icon.gif) center right no-repeat; - padding-right: 18px; -} -#bodyContent a[href ^="irc://"], -.link-irc { - background: url(discussionitem_icon.gif) center right no-repeat; - padding-right: 18px; -} -#bodyContent a.external[href $=".ogg"], #bodyContent a.external[href $=".OGG"], -#bodyContent a.external[href $=".mid"], #bodyContent a.external[href $=".MID"], -#bodyContent a.external[href $=".midi"], #bodyContent a.external[href $=".MIDI"], -#bodyContent a.external[href $=".mp3"], #bodyContent a.external[href $=".MP3"], -#bodyContent a.external[href $=".wav"], #bodyContent a.external[href $=".WAV"], -#bodyContent a.external[href $=".wma"], #bodyContent a.external[href $=".WMA"], -.link-audio { - background: url("audio.png") center right no-repeat; - padding-right: 13px; -} -#bodyContent a.external[href $=".ogm"], #bodyContent a.external[href $=".OGM"], -#bodyContent a.external[href $=".avi"], #bodyContent a.external[href $=".AVI"], -#bodyContent a.external[href $=".mpeg"], #bodyContent a.external[href $=".MPEG"], -#bodyContent a.external[href $=".mpg"], #bodyContent a.external[href $=".MPG"], -.link-video { - background: url("video.png") center right no-repeat; - padding-right: 13px; -} -#bodyContent a.external[href $=".pdf"], #bodyContent a.external[href $=".PDF"], -#bodyContent a.external[href *=".pdf#"], #bodyContent a.external[href *=".PDF#"], -#bodyContent a.external[href *=".pdf?"], #bodyContent a.external[href *=".PDF?"], -.link-document { - background: url("document.png") center right no-repeat; - padding-right: 12px; -} - -/* disable interwiki styling */ -#bodyContent a.extiw, -#bodyContent a.extiw:active { - color: #36b; - background: none; - padding: 0; -} -#bodyContent a.external { - color: #36b; -} -/* this can be used in the content area to switch off -special external link styling */ -#bodyContent .plainlinks a { - background: none !important; - padding: 0 !important; -} -/* -** Structural Elements -*/ - -/* -** general portlet styles (elements in the quickbar) -*/ -.portlet { - border: none; - margin: 0 0 .5em; - padding: 0; - float: none; - width: 11.6em; - overflow: hidden; -} -.portlet h4 { - font-size: 95%; - font-weight: normal; - white-space: nowrap; -} -.portlet h5 { - background: transparent; - padding: 0 1em 0 .5em; - display: inline; - height: 1em; - text-transform: lowercase; - font-size: 91%; - font-weight: normal; - white-space: nowrap; -} -.portlet h6 { - background: #ffae2e; - border: 1px solid #2f6fab; - border-style: solid solid none solid; - padding: 0 1em 0 1em; - text-transform: lowercase; - display: block; - font-size: 1em; - height: 1.2em; - font-weight: normal; - white-space: nowrap; -} -.pBody { - font-size: 95%; - background-color: white; - color: black; - border-collapse: collapse; - border: 1px solid #aaa; - padding: 0 .8em .3em .5em; -} -.portlet h1, -.portlet h2, -.portlet h3, -.portlet h4 { - margin: 0; - padding: 0; -} -.portlet ul { - line-height: 1.5em; - list-style-type: square; - list-style-image: url(bullet.gif); - font-size: 95%; -} -.portlet li { - padding: 0; - margin: 0; -} - -/* -** Logo properties -*/ - -@media handheld { - #p-logo { display: none } -} - -/* -** the navigation portlet -*/ - -#p-navigation .pBody { - padding-right: 0; -} - -#p-navigation li.active a, #p-navigation li.active a:hover { - text-decoration: none; - font-weight: bold; -} - - -/* -** Search portlet -*/ -input.searchButton { - margin-top: 1px; - font-size: 95%; -} -#searchGoButton { - padding-left: .5em; - padding-right: .5em; - font-weight: bold; -} -#searchInput { - width: 10.9em; - margin: 0; - font-size: 95%; -} -#p-search .pBody { - padding: .5em .4em .4em .4em; - text-align: center; -} - -/* -** the personal toolbar -*/ -#p-personal ul { - text-transform: lowercase; -} -#p-personal li.active { - font-weight: bold; -} -/* -** the page-related actions- page/talk, edit etc -*/ -#p-cactions .hiddenStructure { - display: none; -} -#p-cactions li a { - text-transform: lowercase; -} - -/* TODO: #t-iscite is only used by the Cite extension, come up with some - * system which allows extensions to add to this file on the fly - */ -#t-ispermalink, #t-iscite { - color: #999; -} -/* -** footer -*/ -#footer { - background-color: white; - border-top: 1px solid #fabd23; - border-bottom: 1px solid #fabd23; - margin: .6em 0 1em 0; - padding: .4em 0 1.2em 0; - text-align: center; - font-size: 90%; -} -#footer li { - display: inline; - margin: 0 1.3em; -} -/* hide from incapable browsers */ -head:first-child+body #footer li { white-space: nowrap; } -#f-poweredbyico, #f-copyrightico { - margin: 0 8px; - position: relative; - top: -2px; /* Bump it up just a tad */ -} -#f-poweredbyico { - float: right; - height: 1%; -} -#f-copyrightico { - float: left; - height: 1%; -} - -/* js pref toc */ -#preftoc { - margin: 0; - padding: 0; - width: 100%; - clear: both; -} -#preftoc li { - background-color: #f0f0f0; - color: #000; -} -#preftoc li.selected { - font-weight: bold; - background-color: #f9f9f9; - border: 1px solid #aaa; - border-bottom: none; - cursor: default; - top: 1px; - padding-top: 2px; - margin-right: -3px; -} -#preftoc > li.selected { - top: 2px; -} -#preftoc a, -#preftoc a:active { - display: block; - color: #000; - padding: 0 .7em; - position: relative; - text-decoration: none; -} -#preftoc li.selected a { - cursor: default; - text-decoration: none; -} -#prefcontrol { - padding-top: 2em; - clear: both; -} -#preferences { - margin: 0; - border: 1px solid #aaa; - clear: both; - padding: 1.5em; - background-color: #F9F9F9; -} -.prefsection { - border: none; - padding: 0; - margin: 0; -} -.prefsection fieldset { - border: 1px solid #aaa; - float: left; - margin-right: 2em; -} -.prefsection legend { - font-weight: bold; -} -.prefsection table, .prefsection legend { - background-color: #F9F9F9; -} -div.prefsectiontip { - font-size: 95%; - margin-top: 0; - background-color: #FFC1C1; - padding: .2em .7em; - clear: both; -} -.btnSavePrefs { - font-weight: bold; - padding-left: .3em; - padding-right: .3em; -} - -.preferences-login { - clear: both; - margin-bottom: 1.5em; -} - -.prefcache { - font-size: 90%; - margin-top: 2em; -} - -div#userloginForm form, -div#userlogin form#userlogin2 { - margin: 0 3em 1em 0; - border: 1px solid #aaa; - clear: both; - padding: 1.5em 2em; - background-color: #f9f9f9; - float: left; -} - -div#userloginForm table, -div#userlogin form#userlogin2 table { - background-color: #f9f9f9; -} - -div#userloginForm h2, -div#userlogin form#userlogin2 h2 { - padding-top: 0; -} - -div#userlogin .captcha { - border: 1px solid #bbb; - padding: 1.5em 2em; - width: 400px; - background-color: white; -} - - -#userloginprompt, #languagelinks { - font-size: 85%; -} - -#login-sectiontip { - font-size: 85%; - line-height: 1.2; - padding-top: 2em; -} - -#userlogin .loginText, #userlogin .loginPassword { - width: 12em; -} - -#userloginlink a, #wpLoginattempt, #wpCreateaccount { - font-weight: bold; -} - -/* more IE fixes */ -/* float/negative margin brokenness */ -* html #footer {margin-top: 0;} -* html #column-content { - display: inline; - margin-bottom: 0; -} -* html div.editsection { font-size: smaller; } -#pagehistory li.selected { position: relative; } - -/* Mac IE 5.0 fix; floated content turns invisible */ -* > html #column-content { - float: none; -} -* > html #column-one { - position: absolute; - left: 0; - top: 0; -} -* > html #footer { - margin-left: 13.2em; -} -.redirectText { - font-size: 150%; - margin: 5px; -} - -.printfooter { - display: none; -} - -.not-patrolled { - background-color: #ffa; -} -div.patrollink { - font-size: 75%; - text-align: right; -} -span.newpage, span.minor, span.searchmatch, span.bot { - font-weight: bold; -} -span.unpatrolled { - font-weight: bold; - color: red; -} - -span.searchmatch { - color: red; -} -.sharedUploadNotice { - font-style: italic; -} - -span.updatedmarker { - color: black; - background-color: #0f0; -} - -table.gallery { - border: 1px solid #ccc; - margin: 2px; - padding: 2px; - background-color: white; -} - -table.gallery tr { - vertical-align: top; -} - -table.gallery td { - vertical-align: top; - background-color: #f9f9f9; - border: solid 2px white; -} - -/* Keep this temporarily so that cached pages will display right */ -table.gallery td.galleryheader { - text-align: center; - font-weight: bold; -} -table.gallery caption { - font-weight: bold; -} - -div.gallerybox { - margin: 2px; - width: 150px; -} - -div.gallerybox div.thumb { - text-align: center; - border: 1px solid #ccc; - margin: 2px; -} - -div.gallerytext { - font-size: 94%; - padding: 2px 4px; -} - -span.comment { - font-style: italic; -} - -span.changedby { - font-size: 95%; -} - -.previewnote { - text-indent: 3em; - color: #c00; - border-bottom: 1px solid #aaa; - padding-bottom: 1em; - margin-bottom: 1em; -} - -.previewnote p { - margin: 0; - padding: 0; -} - -.editExternally { - border: 1px solid gray; - background-color: #ffffff; - padding: 3px; - margin-top: 0.5em; - float: left; - font-size: small; - text-align: center; -} -.editExternallyHelp { - font-style: italic; - color: gray; -} - -li span.deleted, span.history-deleted { - text-decoration: line-through; - color: #888; - font-style: italic; -} - -.toggle { - margin-left: 2em; - text-indent: -2em; -} - -/* Classes for EXIF data display */ -table.mw_metadata { - font-size: 0.8em; - margin-left: 0.5em; - margin-bottom: 0.5em; - width: 300px; -} - -table.mw_metadata caption { - font-weight: bold; -} - -table.mw_metadata th { - font-weight: normal; -} - -table.mw_metadata td { - padding: 0.1em; -} - -table.mw_metadata { - border: none; - border-collapse: collapse; -} - -table.mw_metadata td, table.mw_metadata th { - text-align: center; - border: 1px solid #aaaaaa; - padding-left: 0.1em; - padding-right: 0.1em; -} - -table.mw_metadata th { - background-color: #f9f9f9; -} - -table.mw_metadata td { - background-color: #fcfcfc; -} - -table.collapsed tr.collapsable { - display: none; -} - - -/* filetoc */ -ul#filetoc { - text-align: center; - border: 1px solid #aaaaaa; - background-color: #f9f9f9; - padding: 5px; - font-size: 95%; - margin-bottom: 0.5em; - margin-left: 0; - margin-right: 0; -} - -#filetoc li { - display: inline; - list-style-type: none; - padding-right: 2em; -} - -input#wpSummary { - width: 80%; -} - -/* @bug 1714 */ -input#wpSave, input#wpDiff { - margin-right: 0.33em; -} - -#editform .editOptions { - display: inline; -} - -#wpSave { - font-weight: bold; -} - -/* Classes for article validation */ - -table.revisionform_default { - border: 1px solid #000000; -} - -table.revisionform_focus { - border: 1px solid #000000; - background-color:#00BBFF; -} - -tr.revision_tr_default { - background-color:#EEEEEE; -} - -tr.revision_tr_first { - background-color:#DDDDDD; -} - -p.revision_saved { - color: green; - font-weight:bold; -} - -#mw_trackbacks { - border: solid 1px #bbbbff; - background-color: #eeeeff; - padding: 0.2em; -} - - -/* Allmessages table */ - -#allmessagestable th { - background-color: #b2b2ff; -} - -#allmessagestable tr.orig { - background-color: #ffe2e2; -} - -#allmessagestable tr.new { - background-color: #e2ffe2; -} - -#allmessagestable tr.def { - background-color: #f0f0ff; -} - - -/* noarticletext */ -div.noarticletext { - border: 1px solid #ccc; - background: #fff; - padding: .2em 1em; - color: #000; -} - -div#searchTargetContainer { - left: 10px; - top: 10px; - width: 90%; - background: white; -} - -div#searchTarget { - padding: 3px; - margin: 5px; - background: #F0F0F0; - border: solid 1px blue; -} - -div#searchTarget ul li { - list-style: none; -} - -div#searchTarget ul li:before { - color: orange; - content: "\00BB \0020"; -} - -div.multipageimagenavbox { - border: solid 1px silver; - padding: 4px; - margin: 1em; - -moz-border-radius: 6px; - background: #f0f0f0; -} - -div.multipageimagenavbox div.thumb { - border: none; - margin-left: 2em; - margin-right: 2em; -} - -div.multipageimagenavbox hr { - margin: 6px; -} - -table.multipageimage td { - text-align: center; -} - -/** Special:Version */ - -table#sv-ext, table#sv-hooks { - margin: 1em; - padding:0em; -} - -#sv-ext td, #sv-hooks td, -#sv-ext th, #sv-hooks th { - border: 1px solid #A0A0A0; - padding: 0 0.15em 0 0.15em; -} -#sv-ext th, #sv-hooks th { - background-color: #F0F0F0; - color: black; - padding: 0 0.15em 0 0.15em; -} -tr.sv-space{ - height: 0.8em; - border:none; -} -tr.sv-space td { display: none; } - -/* - Table pager (e.g. Special:Imagelist) - - remove underlines from the navigation link - - collapse borders - - set the borders to outsets (similar to Special:Allmessages) - - remove line wrapping for all td and th, set background color - - restore line wrapping for the last two table cells (description and size) -*/ -.TablePager_nav a { text-decoration: none; } -.TablePager { border-collapse: collapse; } -.TablePager, .TablePager td, .TablePager th { - border: 0.15em solid #777777; - padding: 0 0.15em 0 0.15em; -} -.TablePager th { background-color: #eeeeff } -.TablePager td { background-color: #ffffff } -.TablePager tr:hover td { background-color: #eeeeff } - -.imagelist td, .imagelist th { white-space: nowrap } -.imagelist .TablePager_col_links { background-color: #eeeeff } -.imagelist .TablePager_col_img_description { white-space: normal } -.imagelist th.TablePager_sort { background-color: #ccccff } - -.templatesUsed { margin-top: 1.5em; } - -.mw-summary-preview { - margin: 0.1em 0; -} -@media handheld { - .nonessential { - /* Kill big bulky stuff that will clog up the screen */ - display: none; - } -} - -/** - * Here is some stuff that's ACTUALLY COMMON TO ALL SKINS. - * When the day comes, it can be moved to a *real* common.css. - */ -.mw-plusminus-null { color: #aaa; } -.texvc { direction: ltr; unicode-bidi: embed; } -/* Stop floats from intruding into edit area in previews */ -#toolbar, #wpTextbox1 { clear: both; } \ No newline at end of file diff --git a/pyyaml/YAMLish_files/index.js b/pyyaml/YAMLish_files/index.js deleted file mode 100644 index 42c9619..0000000 --- a/pyyaml/YAMLish_files/index.js +++ /dev/null @@ -1,9 +0,0 @@ -/* generated javascript */ -var skin = 'monobook'; -var stylepath = '/wiki/skins'; - -/* MediaWiki:Common.js */ -/* Any JavaScript here will be loaded for all users on every page load. */ - -/* MediaWiki:Monobook.js (deprecated; migrate to Common.js!) */ -/* Deprecated; use [[MediaWiki:common.js]] */ \ No newline at end of file diff --git a/pyyaml/YAMLish_files/poweredby_mediawiki_88x31.png b/pyyaml/YAMLish_files/poweredby_mediawiki_88x31.png deleted file mode 100644 index ce1765d..0000000 Binary files a/pyyaml/YAMLish_files/poweredby_mediawiki_88x31.png and /dev/null differ diff --git a/pyyaml/YAMLish_files/wikibits.js b/pyyaml/YAMLish_files/wikibits.js deleted file mode 100644 index 6299e5f..0000000 --- a/pyyaml/YAMLish_files/wikibits.js +++ /dev/null @@ -1,1246 +0,0 @@ -// MediaWiki JavaScript support functions - -var clientPC = navigator.userAgent.toLowerCase(); // Get client info -var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1) - && (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1)); -var is_safari = ((clientPC.indexOf('applewebkit')!=-1) && (clientPC.indexOf('spoofer')==-1)); -var is_khtml = (navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled )); -// For accesskeys -var is_ff2_win = (clientPC.indexOf('firefox/2')!=-1 || clientPC.indexOf('minefield/3')!=-1) && clientPC.indexOf('windows')!=-1; -var is_ff2_x11 = (clientPC.indexOf('firefox/2')!=-1 || clientPC.indexOf('minefield/3')!=-1) && clientPC.indexOf('x11')!=-1; -if (clientPC.indexOf('opera') != -1) { - var is_opera = true; - var is_opera_preseven = (window.opera && !document.childNodes); - var is_opera_seven = (window.opera && document.childNodes); -} - -// Global external objects used by this script. -/*extern ta, stylepath, skin */ - -// add any onload functions in this hook (please don't hard-code any events in the xhtml source) -var doneOnloadHook; - -if (!window.onloadFuncts) { - var onloadFuncts = []; -} - -function addOnloadHook(hookFunct) { - // Allows add-on scripts to add onload functions - onloadFuncts[onloadFuncts.length] = hookFunct; -} - -function hookEvent(hookName, hookFunct) { - if (window.addEventListener) { - window.addEventListener(hookName, hookFunct, false); - } else if (window.attachEvent) { - window.attachEvent("on" + hookName, hookFunct); - } -} - -// document.write special stylesheet links -if (typeof stylepath != 'undefined' && typeof skin != 'undefined') { - if (is_opera_preseven) { - document.write(''); - } else if (is_opera_seven) { - document.write(''); - } else if (is_khtml) { - document.write(''); - } -} - -if (wgBreakFrames) { - // Un-trap us from framesets - if (window.top != window) { - window.top.location = window.location; - } -} - -// for enhanced RecentChanges -function toggleVisibility(_levelId, _otherId, _linkId) { - var thisLevel = document.getElementById(_levelId); - var otherLevel = document.getElementById(_otherId); - var linkLevel = document.getElementById(_linkId); - if (thisLevel.style.display == 'none') { - thisLevel.style.display = 'block'; - otherLevel.style.display = 'none'; - linkLevel.style.display = 'inline'; - } else { - thisLevel.style.display = 'none'; - otherLevel.style.display = 'inline'; - linkLevel.style.display = 'none'; - } -} - -function historyRadios(parent) { - var inputs = parent.getElementsByTagName('input'); - var radios = []; - for (var i = 0; i < inputs.length; i++) { - if (inputs[i].name == "diff" || inputs[i].name == "oldid") { - radios[radios.length] = inputs[i]; - } - } - return radios; -} - -// check selection and tweak visibility/class onclick -function diffcheck() { - var dli = false; // the li where the diff radio is checked - var oli = false; // the li where the oldid radio is checked - var hf = document.getElementById('pagehistory'); - if (!hf) { - return true; - } - var lis = hf.getElementsByTagName('li'); - for (var i=0;i= 0) ? "-" : "+") + ((tzHour < 10) ? "0" : "") + tzHour + ((tzMin < 10) ? "0" : "") + tzMin; - if (tz != tzString) { - var junk = msg.split('$1'); - document.write(junk[0] + "UTC" + tzString + junk[1]); - } -} - -function unhidetzbutton() { - var tzb = document.getElementById('guesstimezonebutton'); - if (tzb) { - tzb.style.display = 'inline'; - } -} - -// in [-]HH:MM format... -// won't yet work with non-even tzs -function fetchTimezone() { - // FIXME: work around Safari bug - var localclock = new Date(); - // returns negative offset from GMT in minutes - var tzRaw = localclock.getTimezoneOffset(); - var tzHour = Math.floor( Math.abs(tzRaw) / 60); - var tzMin = Math.abs(tzRaw) % 60; - var tzString = ((tzRaw >= 0) ? "-" : "") + ((tzHour < 10) ? "0" : "") + tzHour + - ":" + ((tzMin < 10) ? "0" : "") + tzMin; - return tzString; -} - -function guessTimezone(box) { - document.getElementsByName("wpHourDiff")[0].value = fetchTimezone(); -} - -function showTocToggle() { - if (document.createTextNode) { - // Uses DOM calls to avoid document.write + XHTML issues - - var linkHolder = document.getElementById('toctitle'); - if (!linkHolder) { - return; - } - - var outerSpan = document.createElement('span'); - outerSpan.className = 'toctoggle'; - - var toggleLink = document.createElement('a'); - toggleLink.id = 'togglelink'; - toggleLink.className = 'internal'; - toggleLink.href = 'javascript:toggleToc()'; - toggleLink.appendChild(document.createTextNode(tocHideText)); - - outerSpan.appendChild(document.createTextNode('[')); - outerSpan.appendChild(toggleLink); - outerSpan.appendChild(document.createTextNode(']')); - - linkHolder.appendChild(document.createTextNode(' ')); - linkHolder.appendChild(outerSpan); - - var cookiePos = document.cookie.indexOf("hidetoc="); - if (cookiePos > -1 && document.cookie.charAt(cookiePos + 8) == 1) { - toggleToc(); - } - } -} - -function changeText(el, newText) { - // Safari work around - if (el.innerText) { - el.innerText = newText; - } else if (el.firstChild && el.firstChild.nodeValue) { - el.firstChild.nodeValue = newText; - } -} - -function toggleToc() { - var toc = document.getElementById('toc').getElementsByTagName('ul')[0]; - var toggleLink = document.getElementById('togglelink'); - - if (toc && toggleLink && toc.style.display == 'none') { - changeText(toggleLink, tocHideText); - toc.style.display = 'block'; - document.cookie = "hidetoc=0"; - } else { - changeText(toggleLink, tocShowText); - toc.style.display = 'none'; - document.cookie = "hidetoc=1"; - } -} - -var mwEditButtons = []; -var mwCustomEditButtons = []; // eg to add in MediaWiki:Common.js - -// this function generates the actual toolbar buttons with localized text -// we use it to avoid creating the toolbar where javascript is not enabled -function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) { - // Don't generate buttons for browsers which don't fully - // support it. - mwEditButtons[mwEditButtons.length] = - {"imageId": imageId, - "imageFile": imageFile, - "speedTip": speedTip, - "tagOpen": tagOpen, - "tagClose": tagClose, - "sampleText": sampleText}; -} - -// this function generates the actual toolbar buttons with localized text -// we use it to avoid creating the toolbar where javascript is not enabled -function mwInsertEditButton(parent, item) { - var image = document.createElement("img"); - image.width = 23; - image.height = 22; - image.className = "mw-toolbar-editbutton"; - if (item.imageId) image.id = item.imageId; - image.src = item.imageFile; - image.border = 0; - image.alt = item.speedTip; - image.title = item.speedTip; - image.style.cursor = "pointer"; - image.onclick = function() { - insertTags(item.tagOpen, item.tagClose, item.sampleText); - return false; - }; - - parent.appendChild(image); - return true; -} - -function mwSetupToolbar() { - var toolbar = document.getElementById('toolbar'); - if (!toolbar) { return false; } - - var textbox = document.getElementById('wpTextbox1'); - if (!textbox) { return false; } - - // Don't generate buttons for browsers which don't fully - // support it. - if (!document.selection && textbox.selectionStart === null) { - return false; - } - - for (var i = 0; i < mwEditButtons.length; i++) { - mwInsertEditButton(toolbar, mwEditButtons[i]); - } - for (var i = 0; i < mwCustomEditButtons.length; i++) { - mwInsertEditButton(toolbar, mwCustomEditButtons[i]); - } - return true; -} - -function escapeQuotes(text) { - var re = new RegExp("'","g"); - text = text.replace(re,"\\'"); - re = new RegExp("\\n","g"); - text = text.replace(re,"\\n"); - return escapeQuotesHTML(text); -} - -function escapeQuotesHTML(text) { - var re = new RegExp('&',"g"); - text = text.replace(re,"&"); - re = new RegExp('"',"g"); - text = text.replace(re,"""); - re = new RegExp('<',"g"); - text = text.replace(re,"<"); - re = new RegExp('>',"g"); - text = text.replace(re,">"); - return text; -} - -// apply tagOpen/tagClose to selection in textarea, -// use sampleText instead of selection if there is none -// copied and adapted from phpBB -function insertTags(tagOpen, tagClose, sampleText) { - var txtarea; - if (document.editform) { - txtarea = document.editform.wpTextbox1; - } else { - // some alternate form? take the first one we can find - var areas = document.getElementsByTagName('textarea'); - txtarea = areas[0]; - } - - // IE - if (document.selection && !is_gecko) { - var theSelection = document.selection.createRange().text; - if (!theSelection) { - theSelection=sampleText; - } - txtarea.focus(); - if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any - theSelection = theSelection.substring(0, theSelection.length - 1); - document.selection.createRange().text = tagOpen + theSelection + tagClose + " "; - } else { - document.selection.createRange().text = tagOpen + theSelection + tagClose; - } - - // Mozilla - } else if(txtarea.selectionStart || txtarea.selectionStart == '0') { - var replaced = false; - var startPos = txtarea.selectionStart; - var endPos = txtarea.selectionEnd; - if (endPos-startPos) { - replaced = true; - } - var scrollTop = txtarea.scrollTop; - var myText = (txtarea.value).substring(startPos, endPos); - if (!myText) { - myText=sampleText; - } - var subst; - if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any - subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " "; - } else { - subst = tagOpen + myText + tagClose; - } - txtarea.value = txtarea.value.substring(0, startPos) + subst + - txtarea.value.substring(endPos, txtarea.value.length); - txtarea.focus(); - //set new selection - if (replaced) { - var cPos = startPos+(tagOpen.length+myText.length+tagClose.length); - txtarea.selectionStart = cPos; - txtarea.selectionEnd = cPos; - } else { - txtarea.selectionStart = startPos+tagOpen.length; - txtarea.selectionEnd = startPos+tagOpen.length+myText.length; - } - txtarea.scrollTop = scrollTop; - - // All other browsers get no toolbar. - // There was previously support for a crippled "help" - // bar, but that caused more problems than it solved. - } - // reposition cursor if possible - if (txtarea.createTextRange) { - txtarea.caretPos = document.selection.createRange().duplicate(); - } -} - - -/** - * Set the accesskey prefix based on browser detection. - */ -var tooltipAccessKeyPrefix = 'alt-'; -if (is_opera) { - tooltipAccessKeyPrefix = 'shift-esc-'; -} else if (is_safari - || navigator.userAgent.toLowerCase().indexOf('mac') != -1 - || navigator.userAgent.toLowerCase().indexOf('konqueror') != -1 ) { - tooltipAccessKeyPrefix = 'ctrl-'; -} else if (is_ff2_x11 || is_ff2_win) { - tooltipAccessKeyPrefix = 'alt-shift-'; -} -var tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?.\]$/; - -/** - * Add the appropriate prefix to the accesskey shown in the tooltip. - * If the nodeList parameter is given, only those nodes are updated; - * otherwise, all the nodes that will probably have accesskeys by - * default are updated. - * - * @param Array nodeList -- list of elements to update - */ -function updateTooltipAccessKeys( nodeList ) { - if ( !nodeList ) { - // skins without a "column-one" element don't seem to have links with accesskeys either - var columnOne = document.getElementById("column-one"); - if ( columnOne ) - updateTooltipAccessKeys( columnOne.getElementsByTagName("a") ); - // these are rare enough that no such optimization is needed - updateTooltipAccessKeys( document.getElementsByTagName("input") ); - updateTooltipAccessKeys( document.getElementsByTagName("label") ); - return; - } - - for ( var i = 0; i < nodeList.length; i++ ) { - var element = nodeList[i]; - var tip = element.getAttribute("title"); - var key = element.getAttribute("accesskey"); - if ( key && tooltipAccessKeyRegexp.exec(tip) ) { - tip = tip.replace(tooltipAccessKeyRegexp, - "["+tooltipAccessKeyPrefix+key+"]"); - element.setAttribute("title", tip ); - } - } -} - -/** - * Add a link to one of the portlet menus on the page, including: - * - * p-cactions: Content actions (shown as tabs above the main content in Monobook) - * p-personal: Personal tools (shown at the top right of the page in Monobook) - * p-navigation: Navigation - * p-tb: Toolbox - * - * This function exists for the convenience of custom JS authors. All - * but the first three parameters are optional, though providing at - * least an id and a tooltip is recommended. - * - * By default the new link will be added to the end of the list. To - * add the link before a given existing item, pass the DOM node of - * that item (easily obtained with document.getElementById()) as the - * nextnode parameter; to add the link _after_ an existing item, pass - * the node's nextSibling instead. - * - * @param String portlet -- id of the target portlet ("p-cactions", "p-personal", "p-navigation" or "p-tb") - * @param String href -- link URL - * @param String text -- link text (will be automatically lowercased by CSS for p-cactions in Monobook) - * @param String id -- id of the new item, should be unique and preferably have the appropriate prefix ("ca-", "pt-", "n-" or "t-") - * @param String tooltip -- text to show when hovering over the link, without accesskey suffix - * @param String accesskey -- accesskey to activate this link (one character, try to avoid conflicts) - * @param Node nextnode -- the DOM node before which the new item should be added, should be another item in the same list - * - * @return Node -- the DOM node of the new item (an LI element) or null - */ -function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) { - var node = document.getElementById(portlet); - if ( !node ) return null; - node = node.getElementsByTagName( "ul" )[0]; - if ( !node ) return null; - - var link = document.createElement( "a" ); - link.appendChild( document.createTextNode( text ) ); - link.href = href; - - var item = document.createElement( "li" ); - item.appendChild( link ); - if ( id ) item.id = id; - - if ( accesskey ) { - link.setAttribute( "accesskey", accesskey ); - tooltip += " ["+accesskey+"]"; - } - if ( tooltip ) { - link.setAttribute( "title", tooltip ); - } - if ( accesskey && tooltip ) { - updateTooltipAccessKeys( new Array( link ) ); - } - - if ( nextnode && nextnode.parentNode == node ) - node.insertBefore( item, nextnode ); - else - node.appendChild( item ); // IE compatibility (?) - - return item; -} - - -/** - * Set up accesskeys/tooltips from the deprecated ta array. If doId - * is specified, only set up for that id. Note that this function is - * deprecated and will not be supported indefinitely -- use - * updateTooltipAccessKey() instead. - * - * @param mixed doId string or null - */ -function akeytt( doId ) { - // A lot of user scripts (and some of the code below) break if - // ta isn't defined, so we make sure it is. Explictly using - // window.ta avoids a "ta is not defined" error. - if (!window.ta) window.ta = new Array; - - // Make a local, possibly restricted, copy to avoid clobbering - // the original. - var ta; - if ( doId ) { - ta = new Array; - ta[doId] = window.ta[doId]; - } else { - ta = window.ta; - } - - // Now deal with evil deprecated ta - var watchCheckboxExists = document.getElementById( 'wpWatchthis' ) ? true : false; - for (var id in ta) { - var n = document.getElementById(id); - if (n) { - var a = null; - var ak = ''; - // Are we putting accesskey in it - if (ta[id][0].length > 0) { - // Is this object a object? If not assume it's the next child. - - if (n.nodeName.toLowerCase() == "a") { - a = n; - } else { - a = n.childNodes[0]; - } - // Don't add an accesskey for the watch tab if the watch - // checkbox is also available. - if (a && ((id != 'ca-watch' && id != 'ca-unwatch') || !watchCheckboxExists)) { - a.accessKey = ta[id][0]; - ak = ' ['+tooltipAccessKeyPrefix+ta[id][0]+']'; - } - } else { - // We don't care what type the object is when assigning tooltip - a = n; - ak = ''; - } - - if (a) { - a.title = ta[id][1]+ak; - } - } - } -} - -function setupRightClickEdit() { - if (document.getElementsByTagName) { - var spans = document.getElementsByTagName('span'); - for (var i = 0; i < spans.length; i++) { - var el = spans[i]; - if(el.className == 'editsection') { - addRightClickEditHandler(el); - } - } - } -} - -function addRightClickEditHandler(el) { - for (var i = 0; i < el.childNodes.length; i++) { - var link = el.childNodes[i]; - if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') { - var editHref = link.getAttribute('href'); - // find the enclosing (parent) header - var prev = el.parentNode; - if (prev && prev.nodeType == 1 && - prev.nodeName.match(/^[Hh][1-6]$/)) { - prev.oncontextmenu = function(e) { - if (!e) { e = window.event; } - // e is now the event in all browsers - var targ; - if (e.target) { targ = e.target; } - else if (e.srcElement) { targ = e.srcElement; } - if (targ.nodeType == 3) { // defeat Safari bug - targ = targ.parentNode; - } - // targ is now the target element - - // We don't want to deprive the noble reader of a context menu - // for the section edit link, do we? (Might want to extend this - // to all 's?) - if (targ.nodeName.toLowerCase() != 'a' - || targ.parentNode.className != 'editsection') { - document.location = editHref; - return false; - } - return true; - }; - } - } - } -} - -var checkboxes; -var lastCheckbox; - -function setupCheckboxShiftClick() { - checkboxes = []; - lastCheckbox = null; - var inputs = document.getElementsByTagName('input'); - addCheckboxClickHandlers(inputs); -} - -function addCheckboxClickHandlers(inputs, start) { - if ( !start) start = 0; - - var finish = start + 250; - if ( finish > inputs.length ) - finish = inputs.length; - - for ( var i = start; i < finish; i++ ) { - var cb = inputs[i]; - if ( !cb.type || cb.type.toLowerCase() != 'checkbox' ) - continue; - cb.index = checkboxes.push(cb) - 1; - cb.onmouseup = checkboxMouseupHandler; - } - - if ( finish < inputs.length ) { - setTimeout( function () { - addCheckboxClickHandlers(inputs, finish); - }, 200 ); - } -} - -function checkboxMouseupHandler(e) { - if (typeof e == 'undefined') { - e = window.event; - } - if ( !e.shiftKey || lastCheckbox === null ) { - lastCheckbox = this.index; - return true; - } - var endState = !this.checked; - if ( is_opera ) { // opera has already toggled the checkbox by this point - endState = !endState; - } - var start, finish; - if ( this.index < lastCheckbox ) { - start = this.index + 1; - finish = lastCheckbox; - } else { - start = lastCheckbox; - finish = this.index - 1; - } - for (var i = start; i <= finish; ++i ) { - checkboxes[i].checked = endState; - } - lastCheckbox = this.index; - return true; -} - -function toggle_element_activation(ida,idb) { - if (!document.getElementById) { - return; - } - document.getElementById(ida).disabled=true; - document.getElementById(idb).disabled=false; -} - -function toggle_element_check(ida,idb) { - if (!document.getElementById) { - return; - } - document.getElementById(ida).checked=true; - document.getElementById(idb).checked=false; -} - -function fillDestFilename(id) { - if (!document.getElementById) { - return; - } - var path = document.getElementById(id).value; - // Find trailing part - var slash = path.lastIndexOf('/'); - var backslash = path.lastIndexOf('\\'); - var fname; - if (slash == -1 && backslash == -1) { - fname = path; - } else if (slash > backslash) { - fname = path.substring(slash+1, 10000); - } else { - fname = path.substring(backslash+1, 10000); - } - - // Capitalise first letter and replace spaces by underscores - fname = fname.charAt(0).toUpperCase().concat(fname.substring(1,10000)).replace(/ /g, '_'); - - // Output result - var destFile = document.getElementById('wpDestFile'); - if (destFile) { - destFile.value = fname; - } -} - -function scrollEditBox() { - var editBoxEl = document.getElementById("wpTextbox1"); - var scrollTopEl = document.getElementById("wpScrolltop"); - var editFormEl = document.getElementById("editform"); - - if (editBoxEl && scrollTopEl) { - if (scrollTopEl.value) { editBoxEl.scrollTop = scrollTopEl.value; } - editFormEl.onsubmit = function() { - document.getElementById("wpScrolltop").value = document.getElementById("wpTextbox1").scrollTop; - }; - } -} - -hookEvent("load", scrollEditBox); - -var allmessages_nodelist = false; -var allmessages_modified = false; -var allmessages_timeout = false; -var allmessages_running = false; - -function allmessagesmodified() { - allmessages_modified = !allmessages_modified; - allmessagesfilter(); -} - -function allmessagesfilter() { - if ( allmessages_timeout ) - window.clearTimeout( allmessages_timeout ); - - if ( !allmessages_running ) - allmessages_timeout = window.setTimeout( 'allmessagesfilter_do();', 500 ); -} - -function allmessagesfilter_do() { - if ( !allmessages_nodelist ) - return; - - var text = document.getElementById('allmessagesinput').value; - var nodef = allmessages_modified; - - allmessages_running = true; - - for ( var name in allmessages_nodelist ) { - var nodes = allmessages_nodelist[name]; - var display = ( name.indexOf( text ) == -1 ? 'none' : '' ); - - for ( var i = 0; i < nodes.length; i++) - nodes[i].style.display = - ( nodes[i].className == "def" && nodef - ? 'none' : display ); - } - - if ( text != document.getElementById('allmessagesinput').value || - nodef != allmessages_modified ) - allmessagesfilter_do(); // repeat - - allmessages_running = false; -} - -function allmessagesfilter_init() { - if ( allmessages_nodelist ) - return; - - var nodelist = new Array(); - var templist = new Array(); - - var table = document.getElementById('allmessagestable'); - if ( !table ) return; - - var rows = document.getElementsByTagName('tr'); - for ( var i = 0; i < rows.length; i++ ) { - var id = rows[i].getAttribute('id') - if ( id && id.substring(0,16) != 'sp-allmessages-r' ) continue; - templist[ id ] = rows[i]; - } - - var spans = table.getElementsByTagName('span'); - for ( var i = 0; i < spans.length; i++ ) { - var id = spans[i].getAttribute('id') - if ( id && id.substring(0,17) != 'sp-allmessages-i-' ) continue; - if ( !spans[i].firstChild || spans[i].firstChild.nodeType != 3 ) continue; - - var nodes = new Array(); - var row1 = templist[ id.replace('i', 'r1') ]; - var row2 = templist[ id.replace('i', 'r2') ]; - - if ( row1 ) nodes[nodes.length] = row1; - if ( row2 ) nodes[nodes.length] = row2; - nodelist[ spans[i].firstChild.nodeValue ] = nodes; - } - - var k = document.getElementById('allmessagesfilter'); - if (k) { k.style.display = ''; } - - allmessages_nodelist = nodelist; -} - -hookEvent( "load", allmessagesfilter_init ); - -/* - Written by Jonathan Snook, http://www.snook.ca/jonathan - Add-ons by Robert Nyman, http://www.robertnyman.com - Author says "The credit comment is all it takes, no license. Go crazy with it!:-)" - From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/ -*/ -function getElementsByClassName(oElm, strTagName, oClassNames){ - var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName); - var arrReturnElements = new Array(); - var arrRegExpClassNames = new Array(); - if(typeof oClassNames == "object"){ - for(var i=0; i 0) { - if (table.tHead && table.tHead.rows.length > 0) { - firstRow = table.tHead.rows[table.tHead.rows.length-1]; - } else { - firstRow = table.rows[0]; - } - } - if (!firstRow) return; - - // We have a first row: assume it's the header, and make its contents clickable links - for (var i = 0; i < firstRow.cells.length; i++) { - var cell = firstRow.cells[i]; - if ((" "+cell.className+" ").indexOf(" unsortable ") == -1) { - cell.innerHTML += '  ↓'; - } - } - if (ts_alternate_row_colors) { - ts_alternate(table); - } -} - -function ts_getInnerText(el) { - if (typeof el == "string") return el; - if (typeof el == "undefined") { return el }; - if (el.innerText) return el.innerText; // Not needed but it is faster - var str = ""; - - var cs = el.childNodes; - var l = cs.length; - for (var i = 0; i < l; i++) { - switch (cs[i].nodeType) { - case 1: //ELEMENT_NODE - str += ts_getInnerText(cs[i]); - break; - case 3: //TEXT_NODE - str += cs[i].nodeValue; - break; - } - } - return str; -} - -function ts_resortTable(lnk) { - // get the span - var span = lnk.getElementsByTagName('span')[0]; - - var td = lnk.parentNode; - var tr = td.parentNode; - var column = td.cellIndex; - - var table = tr.parentNode; - while (table && !(table.tagName && table.tagName.toLowerCase() == 'table')) - table = table.parentNode; - if (!table) return; - - // Work out a type for the column - if (table.rows.length <= 1) return; - - // Skip the first row if that's where the headings are - var rowStart = (table.tHead && table.tHead.rows.length > 0 ? 0 : 1); - - var itm = ""; - for (var i = rowStart; i < table.rows.length; i++) { - if (table.rows[i].cells.length > column) { - itm = ts_getInnerText(table.rows[i].cells[column]); - itm = itm.replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, ""); - if (itm != "") break; - } - } - - sortfn = ts_sort_caseinsensitive; - if (itm.match(/^\d\d[\/. -][a-zA-Z]{3}[\/. -]\d\d\d\d$/)) - sortfn = ts_sort_date; - if (itm.match(/^\d\d[\/.-]\d\d[\/.-]\d\d\d\d$/)) - sortfn = ts_sort_date; - if (itm.match(/^\d\d[\/.-]\d\d[\/.-]\d\d$/)) - sortfn = ts_sort_date; - if (itm.match(/^[\u00a3$\u20ac]/)) // pound dollar euro - sortfn = ts_sort_currency; - if (itm.match(/^[\d.,]+\%?$/)) - sortfn = ts_sort_numeric; - - var reverse = (span.getAttribute("sortdir") == 'down'); - - var newRows = new Array(); - for (var j = rowStart; j < table.rows.length; j++) { - var row = table.rows[j]; - var keyText = ts_getInnerText(row.cells[column]); - var oldIndex = (reverse ? -j : j); - - newRows[newRows.length] = new Array(row, keyText, oldIndex); - } - - newRows.sort(sortfn); - - var arrowHTML; - if (reverse) { - arrowHTML = '↓'; - newRows.reverse(); - span.setAttribute('sortdir','up'); - } else { - arrowHTML = '↑'; - span.setAttribute('sortdir','down'); - } - - // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones - // don't do sortbottom rows - for (var i = 0; i < newRows.length; i++) { - if ((" "+newRows[i][0].className+" ").indexOf(" sortbottom ") == -1) - table.tBodies[0].appendChild(newRows[i][0]); - } - // do sortbottom rows only - for (var i = 0; i < newRows.length; i++) { - if ((" "+newRows[i][0].className+" ").indexOf(" sortbottom ") != -1) - table.tBodies[0].appendChild(newRows[i][0]); - } - - // Delete any other arrows there may be showing - var spans = getElementsByClassName(tr, "span", "sortarrow"); - for (var i = 0; i < spans.length; i++) { - spans[i].innerHTML = '↓'; - } - span.innerHTML = arrowHTML; - - ts_alternate(table); -} - -function ts_dateToSortKey(date) { - // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX - if (date.length == 11) { - switch (date.substr(3,3).toLowerCase()) { - case "jan": var month = "01"; break; - case "feb": var month = "02"; break; - case "mar": var month = "03"; break; - case "apr": var month = "04"; break; - case "may": var month = "05"; break; - case "jun": var month = "06"; break; - case "jul": var month = "07"; break; - case "aug": var month = "08"; break; - case "sep": var month = "09"; break; - case "oct": var month = "10"; break; - case "nov": var month = "11"; break; - case "dec": var month = "12"; break; - // default: var month = "00"; - } - return date.substr(7,4)+month+date.substr(0,2); - } else if (date.length == 10) { - if (ts_europeandate == false) { - return date.substr(6,4)+date.substr(0,2)+date.substr(3,2); - } else { - return date.substr(6,4)+date.substr(3,2)+date.substr(0,2); - } - } else if (date.length == 8) { - yr = date.substr(6,2); - if (parseInt(yr) < 50) { - yr = '20'+yr; - } else { - yr = '19'+yr; - } - if (ts_europeandate == true) { - return yr+date.substr(3,2)+date.substr(0,2); - } else { - return yr+date.substr(0,2)+date.substr(3,2); - } - } - return "00000000"; -} - -function ts_parseFloat(num) { - if (!num) return 0; - num = parseFloat(num.replace(/,/, "")); - return (isNaN(num) ? 0 : num); -} - -function ts_sort_date(a,b) { - var aa = ts_dateToSortKey(a[1]); - var bb = ts_dateToSortKey(b[1]); - return (aa < bb ? -1 : aa > bb ? 1 : a[2] - b[2]); -} - -function ts_sort_currency(a,b) { - var aa = ts_parseFloat(a[1].replace(/[^0-9.]/g,'')); - var bb = ts_parseFloat(b[1].replace(/[^0-9.]/g,'')); - return (aa != bb ? aa - bb : a[2] - b[2]); -} - -function ts_sort_numeric(a,b) { - var aa = ts_parseFloat(a[1]); - var bb = ts_parseFloat(b[1]); - return (aa != bb ? aa - bb : a[2] - b[2]); -} - -function ts_sort_caseinsensitive(a,b) { - var aa = a[1].toLowerCase(); - var bb = b[1].toLowerCase(); - return (aa < bb ? -1 : aa > bb ? 1 : a[2] - b[2]); -} - -function ts_sort_default(a,b) { - return (a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : a[2] - b[2]); -} - -function ts_alternate(table) { - // Take object table and get all it's tbodies. - var tableBodies = table.getElementsByTagName("tbody"); - // Loop through these tbodies - for (var i = 0; i < tableBodies.length; i++) { - // Take the tbody, and get all it's rows - var tableRows = tableBodies[i].getElementsByTagName("tr"); - // Loop through these rows - // Start at 1 because we want to leave the heading row untouched - for (var j = 0; j < tableRows.length; j++) { - // Check if j is even, and apply classes for both possible results - var oldClasses = tableRows[j].className.split(" "); - var newClassName = ""; - for (var k = 0; k < oldClasses.length; k++) { - if (oldClasses[k] != "" && oldClasses[k] != "even" && oldClasses[k] != "odd") - newClassName += oldClasses[k] + " "; - } - tableRows[j].className = newClassName + (j % 2 == 0 ? "even" : "odd"); - } - } -} - -/* - * End of table sorting code - */ - -function runOnloadHook() { - // don't run anything below this for non-dom browsers - if (doneOnloadHook || !(document.getElementById && document.getElementsByTagName)) { - return; - } - - // set this before running any hooks, since any errors below - // might cause the function to terminate prematurely - doneOnloadHook = true; - - histrowinit(); - unhidetzbutton(); - tabbedprefs(); - updateTooltipAccessKeys( null ); - akeytt( null ); - scrollEditBox(); - setupCheckboxShiftClick(); - sortables_init(); - - // Run any added-on functions - for (var i = 0; i < onloadFuncts.length; i++) { - onloadFuncts[i](); - } -} - -//note: all skins should call runOnloadHook() at the end of html output, -// so the below should be redundant. It's there just in case. -hookEvent("load", runOnloadHook); - -hookEvent("load", mwSetupToolbar); -- cgit