<commit_before>"""
This is the new doc for the objectsRF module.

To Do:
- is the path normalization magic in RFont.__init__ necessary?
- make it so that BaseKerning.clear() uses self._kerning.clear() instead of self._kerning = {}
- check all of BaseKerning to make sure that it doesn't replace self._kerning
- in BaseKerning.__init__ use if kerningDixt is None
- make BaseGroups subclass BaseObject like BaseKerning does?
- add __contains__ to all dict-like base objects
- get right of BaseGroups.findGlyph
- look at notification disabling in RFeatures.__init__
- BaseObject.naked expects the wrapped object to be stored at ._object.
  this is not always true.
- what should be done about the PSHint objects?
"""

import os
from defcon import Font as DefconFont
from robofab import RoboFabError, RoboFabWarning
from robofab.objects.objectsBase import BaseFont, BaseKerning, BaseGroups, BaseInfo, BaseFeatures, BaseLib,\
		BaseGlyph, BaseContour, BaseSegment, BasePoint, BaseBPoint, BaseAnchor, BaseGuide, BaseComponent, \
		relativeBCPIn, relativeBCPOut, absoluteBCPIn, absoluteBCPOut, _box,\
		_interpolate, _interpolatePt, roundPt, addPt,\
		MOVE, LINE, CORNER, CURVE, QCURVE, OFFCURVE,\
		BasePostScriptFontHintValues, postScriptHintDataLibKey, BasePostScriptGlyphHintValues


__all__ = [	"CurrentFont", 
		"CurrentGlyph", 'OpenFont',
		'RFont', 'RGlyph', 'RContour',
		'RPoint', 'RBPoint', 'RAnchor',
		'RComponent'
		]



def CurrentFont():
	"""CurrentFont is not available in objectsRF."""
	return None

def CurrentGlyph():
	"""CurrentGlyph is not available in objectsRF."""
	return None

def OpenFont(path=None, note=None):
	"""Open a font from a path. If path is not given, present the user with a dialog (availability of dialogs will vary)"""
	if not note:
		note = 'select a .ufo directory'
	if not path:
		from robofab.interface.all.dialogs import GetFolder
		path = GetFolder(note)
	if path:
		try:
			return RFont(path)
		except OSError:
			from robofab.interface.all.dialogs import Message
			Message("%s is not a valid .UFO font. But considering it's all XML, why don't  you have a look inside with a simple text editor."%(path))
	else:
		return None
		
def NewFont(familyName=None, styleName=None):
	"""Make a new font object. Initialise with familyName and styleName."""
	new = RFont()
	if familyName is not None:
		new.info.familyName = familyName
	if styleName is not None:
		new.info.styleName = styleName
	return new
	
def AllFonts():
	"""AllFonts is not available in objectsRF."""
	raise NotImplementedError
			
			
class RFont(BaseFont):
	"""
    Font object representing the data in an UFO.
    
        - myFontInstace['A']    access the font as a dictionary with glyphnames as key

    """
	
	_title = "RoboFabFont"

	# available for overriding by subclasses that
	# want to implement their own defcon subclasses.
	_defconFontClass = DefconFont
	_defconObjectSubclasses = {}
	
	def __init__(self, path=None):
		super(RFont, self).__init__()
        # XXX is it really necessary to normalize paths?
		if path is not None:
			self._path = os.path.normpath(os.path.abspath(path))
		else:
			self._path = None
        # load the defcon object
		self._object = DefconFont(path, **self._defconObjectSubclasses)
		self._info = None<commit_msg>Remove the path normalization from __init__.<commit_after>"""
This is the new doc for the objectsRF module.

To Do:
- make it so that BaseKerning.clear() uses self._kerning.clear() instead of self._kerning = {}
- check all of BaseKerning to make sure that it doesn't replace self._kerning
- in BaseKerning.__init__ use if kerningDixt is None
- make BaseGroups subclass BaseObject like BaseKerning does?
- add __contains__ to all dict-like base objects
- get right of BaseGroups.findGlyph
- look at notification disabling in RFeatures.__init__
- BaseObject.naked expects the wrapped object to be stored at ._object.
  this is not always true.
- what should be done about the PSHint objects?
"""

import os
from defcon import Font as DefconFont
from robofab import RoboFabError, RoboFabWarning
from robofab.objects.objectsBase import BaseFont, BaseKerning, BaseGroups, BaseInfo, BaseFeatures, BaseLib,\
		BaseGlyph, BaseContour, BaseSegment, BasePoint, BaseBPoint, BaseAnchor, BaseGuide, BaseComponent, \
		relativeBCPIn, relativeBCPOut, absoluteBCPIn, absoluteBCPOut, _box,\
		_interpolate, _interpolatePt, roundPt, addPt,\
		MOVE, LINE, CORNER, CURVE, QCURVE, OFFCURVE,\
		BasePostScriptFontHintValues, postScriptHintDataLibKey, BasePostScriptGlyphHintValues


__all__ = [	"CurrentFont", 
		"CurrentGlyph", 'OpenFont',
		'RFont', 'RGlyph', 'RContour',
		'RPoint', 'RBPoint', 'RAnchor',
		'RComponent'
		]



def CurrentFont():
	"""CurrentFont is not available in objectsRF."""
	return None

def CurrentGlyph():
	"""CurrentGlyph is not available in objectsRF."""
	return None

def OpenFont(path=None, note=None):
	"""Open a font from a path. If path is not given, present the user with a dialog (availability of dialogs will vary)"""
	if not note:
		note = 'select a .ufo directory'
	if not path:
		from robofab.interface.all.dialogs import GetFolder
		path = GetFolder(note)
	if path:
		try:
			return RFont(path)
		except OSError:
			from robofab.interface.all.dialogs import Message
			Message("%s is not a valid .UFO font. But considering it's all XML, why don't  you have a look inside with a simple text editor."%(path))
	else:
		return None
		
def NewFont(familyName=None, styleName=None):
	"""Make a new font object. Initialise with familyName and styleName."""
	new = RFont()
	if familyName is not None:
		new.info.familyName = familyName
	if styleName is not None:
		new.info.styleName = styleName
	return new
	
def AllFonts():
	"""AllFonts is not available in objectsRF."""
	raise NotImplementedError
			
			
class RFont(BaseFont):
	"""
    Font object representing the data in an UFO.
    
        - myFontInstace['A']    access the font as a dictionary with glyphnames as key

    """
	
	_title = "RoboFabFont"

	# available for overriding by subclasses that
	# want to implement their own defcon subclasses.
	_defconFontClass = DefconFont
	_defconObjectSubclasses = {}
	
	def __init__(self, path=None):
		super(RFont, self).__init__()
        # load the defcon object
		self._object = DefconFont(path, **self._defconObjectSubclasses)
		self._info = None
{'fraction_non_alphanumeric': 0.08753357560436088, 'fraction_numerical': 0.0, 'mean_word_length': 4.279399499582985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6522503', 'n_tokens_mistral': 2076, 'n_tokens_neox': 1932, 'n_words': 712}