repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
estnltk/estnltk
estnltk/mw_verbs/basic_verbchain_detection.py
_suitableVerbExpansion
def _suitableVerbExpansion( foundSubcatChain ): ''' V6tab etteantud jadast osa, mis sobib: *) kui liikmeid on 3, keskmine on konjuktsioon ning esimene ja viimane klapivad, tagastab selle kolmiku; Nt. ei_0 saa_0 lihtsalt välja astuda_? ja_? uttu tõmmata_? ...
python
def _suitableVerbExpansion( foundSubcatChain ): ''' V6tab etteantud jadast osa, mis sobib: *) kui liikmeid on 3, keskmine on konjuktsioon ning esimene ja viimane klapivad, tagastab selle kolmiku; Nt. ei_0 saa_0 lihtsalt välja astuda_? ja_? uttu tõmmata_? ...
V6tab etteantud jadast osa, mis sobib: *) kui liikmeid on 3, keskmine on konjuktsioon ning esimene ja viimane klapivad, tagastab selle kolmiku; Nt. ei_0 saa_0 lihtsalt välja astuda_? ja_? uttu tõmmata_? => astuda ja tõmmata *) kui liikmeid on roh...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L1052-L1080
estnltk/estnltk
estnltk/mw_verbs/basic_verbchain_detection.py
_expandSaamaWithTud
def _expandSaamaWithTud( clauseTokens, clauseID, foundChains ): ''' Meetod, mis määrab spetsiifilised rektsiooniseosed: täiendab 'saama'-verbiga lõppevaid verbijadasid, lisades (v6imalusel) nende l6ppu 'tud'-infiniitverbi (nt. sai tehtud, sai käidud ujumas); Vastavalt leitu...
python
def _expandSaamaWithTud( clauseTokens, clauseID, foundChains ): ''' Meetod, mis määrab spetsiifilised rektsiooniseosed: täiendab 'saama'-verbiga lõppevaid verbijadasid, lisades (v6imalusel) nende l6ppu 'tud'-infiniitverbi (nt. sai tehtud, sai käidud ujumas); Vastavalt leitu...
Meetod, mis määrab spetsiifilised rektsiooniseosed: täiendab 'saama'-verbiga lõppevaid verbijadasid, lisades (v6imalusel) nende l6ppu 'tud'-infiniitverbi (nt. sai tehtud, sai käidud ujumas); Vastavalt leitud laiendustele t2iendab andmeid sisendlistis foundChains;
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L1082-L1130
estnltk/estnltk
estnltk/mw_verbs/basic_verbchain_detection.py
_expandVerbChainsBySubcat
def _expandVerbChainsBySubcat( clauseTokens, clauseID, foundChains, verbSubcat, \ skipQuestionable=False, \ breakOnPunctuation=True ): ''' Meetod, mis proovib laiendada (mitte-'olema') verbid...
python
def _expandVerbChainsBySubcat( clauseTokens, clauseID, foundChains, verbSubcat, \ skipQuestionable=False, \ breakOnPunctuation=True ): ''' Meetod, mis proovib laiendada (mitte-'olema') verbid...
Meetod, mis proovib laiendada (mitte-'olema') verbidega l6ppevaid predikaadifraase, lisades nende lõppu rektsiooniseoste järgi uusi infiniitverbe, nt "kutsub" + "langetama" "püütakse" + "keelustada" "või" "takistada" "ei julgenud" + "arvata", "ei hakka" + "tülita...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L1134-L1282
estnltk/estnltk
estnltk/mw_verbs/basic_verbchain_detection.py
_extractEgaNegFromSent
def _extractEgaNegFromSent( sentTokens, clausesDict, foundChains ): ''' Meetod, mis tuvastab antud lausest 'ega'-predikaadiga seotud eituse(d): ega + sobiv verb. *) Juhtudel kui 'ega'-le j2rgneb juba tuvastatud, positiivse polaarsusega verbiahel (nt ahel mille alguses on käskivas kõneviisis v...
python
def _extractEgaNegFromSent( sentTokens, clausesDict, foundChains ): ''' Meetod, mis tuvastab antud lausest 'ega'-predikaadiga seotud eituse(d): ega + sobiv verb. *) Juhtudel kui 'ega'-le j2rgneb juba tuvastatud, positiivse polaarsusega verbiahel (nt ahel mille alguses on käskivas kõneviisis v...
Meetod, mis tuvastab antud lausest 'ega'-predikaadiga seotud eituse(d): ega + sobiv verb. *) Juhtudel kui 'ega'-le j2rgneb juba tuvastatud, positiivse polaarsusega verbiahel (nt ahel mille alguses on käskivas kõneviisis verb), liidetakse 'ega' olemasoleva ahela ette ning muudetakse ahe...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L1340-L1557
estnltk/estnltk
estnltk/mw_verbs/basic_verbchain_detection.py
_determineVerbChainContextualAmbiguity
def _determineVerbChainContextualAmbiguity( clauseTokens, clauseID, foundChains ): ''' Meetod, mis püüab otsustada iga leitud verbiahela (foundChains liikme) puhul, kas osalauses leidub veel vabu verbe, millega verbiahelat oleks võimalik täiendada; Kui vabu verbe ei leidu, muudab verb...
python
def _determineVerbChainContextualAmbiguity( clauseTokens, clauseID, foundChains ): ''' Meetod, mis püüab otsustada iga leitud verbiahela (foundChains liikme) puhul, kas osalauses leidub veel vabu verbe, millega verbiahelat oleks võimalik täiendada; Kui vabu verbe ei leidu, muudab verb...
Meetod, mis püüab otsustada iga leitud verbiahela (foundChains liikme) puhul, kas osalauses leidub veel vabu verbe, millega verbiahelat oleks võimalik täiendada; Kui vabu verbe ei leidu, muudab verbiahela OTHER_VERBS väärtuse negatiivseks, vastasel juhul ei tee midagi. Sisend 'cl...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L1560-L1653
estnltk/estnltk
estnltk/mw_verbs/basic_verbchain_detection.py
_getMatchingAnalysisIDs
def _getMatchingAnalysisIDs( tokenJson, requiredWordTemplate, discardAnalyses = None ): ''' Tagastab listi tokenJson'i analyysidest, mis sobivad etteantud yksiku sõnamalli või sõnamallide listi mõne elemendiga (requiredWordTemplate võib olla üks WordTemplate või list WordTemplate elementide...
python
def _getMatchingAnalysisIDs( tokenJson, requiredWordTemplate, discardAnalyses = None ): ''' Tagastab listi tokenJson'i analyysidest, mis sobivad etteantud yksiku sõnamalli või sõnamallide listi mõne elemendiga (requiredWordTemplate võib olla üks WordTemplate või list WordTemplate elementide...
Tagastab listi tokenJson'i analyysidest, mis sobivad etteantud yksiku sõnamalli või sõnamallide listi mõne elemendiga (requiredWordTemplate võib olla üks WordTemplate või list WordTemplate elementidega); Kui discardAnalyses on defineeritud (ning on WordTemplate), visatakse mi...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L1665-L1691
estnltk/estnltk
estnltk/grammar/common.py
is_valid_regex
def is_valid_regex(regex): """Function for checking a valid regex.""" if len(regex) == 0: return False try: re.compile(regex) return True except sre_constants.error: return False
python
def is_valid_regex(regex): """Function for checking a valid regex.""" if len(regex) == 0: return False try: re.compile(regex) return True except sre_constants.error: return False
Function for checking a valid regex.
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/grammar/common.py#L29-L37
estnltk/estnltk
estnltk/single_layer_operations/layer_positions.py
delete_left
def delete_left(elem1, elem2): """ xxxxx yyyyy --------- xxx yyyyy """ # assert not (nested(elem1, elem2) or nested(elem2, elem1)), 'deletion not defined for nested elements' if overlapping_right(elem1, elem2): elem1['end'] = elem2['start'] return elem1, elem2
python
def delete_left(elem1, elem2): """ xxxxx yyyyy --------- xxx yyyyy """ # assert not (nested(elem1, elem2) or nested(elem2, elem1)), 'deletion not defined for nested elements' if overlapping_right(elem1, elem2): elem1['end'] = elem2['start'] return elem1, elem2
xxxxx yyyyy --------- xxx yyyyy
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/single_layer_operations/layer_positions.py#L105-L116
estnltk/estnltk
estnltk/single_layer_operations/layer_positions.py
delete_right
def delete_right(elem1, elem2): """ xxxxx yyyyy --------- xxxxx yyy """ # assert not (nested(elem1, elem2) or nested(elem2, elem1)), 'deletion not defined for nested elements' if overlapping_left(elem1, elem2): elem2['start'] = elem1['end'] return elem1, elem2
python
def delete_right(elem1, elem2): """ xxxxx yyyyy --------- xxxxx yyy """ # assert not (nested(elem1, elem2) or nested(elem2, elem1)), 'deletion not defined for nested elements' if overlapping_left(elem1, elem2): elem2['start'] = elem1['end'] return elem1, elem2
xxxxx yyyyy --------- xxxxx yyy
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/single_layer_operations/layer_positions.py#L119-L130
estnltk/estnltk
estnltk/single_layer_operations/layer_positions.py
iterate_intersecting_pairs
def iterate_intersecting_pairs(layer): """ Given a layer of estntltk objects, yields pairwise intersecting elements. Breaks when the layer is changed or deleted after initializing the iterator. """ yielded = set() ri = layer[:] # Shallow copy the layer for i1, elem1 in enumerate(ri): ...
python
def iterate_intersecting_pairs(layer): """ Given a layer of estntltk objects, yields pairwise intersecting elements. Breaks when the layer is changed or deleted after initializing the iterator. """ yielded = set() ri = layer[:] # Shallow copy the layer for i1, elem1 in enumerate(ri): ...
Given a layer of estntltk objects, yields pairwise intersecting elements. Breaks when the layer is changed or deleted after initializing the iterator.
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/single_layer_operations/layer_positions.py#L153-L166
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker.analyze_text
def analyze_text( self, text, **kwargs ): ''' Analyzes given Text for noun phrase chunks. As result of analysis, a layer NOUN_CHUNKS will be attached to the input Text object, containing a noun phrases detected from the Text; Note: for preprocessing the Text,...
python
def analyze_text( self, text, **kwargs ): ''' Analyzes given Text for noun phrase chunks. As result of analysis, a layer NOUN_CHUNKS will be attached to the input Text object, containing a noun phrases detected from the Text; Note: for preprocessing the Text,...
Analyzes given Text for noun phrase chunks. As result of analysis, a layer NOUN_CHUNKS will be attached to the input Text object, containing a noun phrases detected from the Text; Note: for preprocessing the Text, MaltParser is used by default. In order to obtain a de...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L50-L184
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker._getPOS
def _getPOS( self, token, onlyFirst = True ): ''' Returns POS of the current token. ''' if onlyFirst: return token[ANALYSIS][0][POSTAG] else: return [ a[POSTAG] for a in token[ANALYSIS] ]
python
def _getPOS( self, token, onlyFirst = True ): ''' Returns POS of the current token. ''' if onlyFirst: return token[ANALYSIS][0][POSTAG] else: return [ a[POSTAG] for a in token[ANALYSIS] ]
Returns POS of the current token.
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L201-L207
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker._getPhrase
def _getPhrase( self, i, sentence, NPlabels ): ''' Fetches the full length phrase from the position i based on the existing NP phrase annotations (from NPlabels); Returns list of sentence tokens in the phrase, and indices of the phrase; ''' ...
python
def _getPhrase( self, i, sentence, NPlabels ): ''' Fetches the full length phrase from the position i based on the existing NP phrase annotations (from NPlabels); Returns list of sentence tokens in the phrase, and indices of the phrase; ''' ...
Fetches the full length phrase from the position i based on the existing NP phrase annotations (from NPlabels); Returns list of sentence tokens in the phrase, and indices of the phrase;
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L209-L229
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker._getCaseAgreement
def _getCaseAgreement(self, token1, token2): ''' Detects whether there is a morphological case agreement between two consecutive nominals (token1 and token2), and returns the common case, or None if no agreement exists; Applies a special set of rules for detecting agr...
python
def _getCaseAgreement(self, token1, token2): ''' Detects whether there is a morphological case agreement between two consecutive nominals (token1 and token2), and returns the common case, or None if no agreement exists; Applies a special set of rules for detecting agr...
Detects whether there is a morphological case agreement between two consecutive nominals (token1 and token2), and returns the common case, or None if no agreement exists; Applies a special set of rules for detecting agreement on the word in genitive followed by the...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L231-L263
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker._find_phrases
def _find_phrases( self, sentence, syntax_layer, cutPhrases, cutMaxThreshold ): ''' Detects NP phrases by relying on local dependency relations: 1) Identifies potential heads of NP phrases; 2) Identifies consecutive words that can form an NP phrase: 2.1) pote...
python
def _find_phrases( self, sentence, syntax_layer, cutPhrases, cutMaxThreshold ): ''' Detects NP phrases by relying on local dependency relations: 1) Identifies potential heads of NP phrases; 2) Identifies consecutive words that can form an NP phrase: 2.1) pote...
Detects NP phrases by relying on local dependency relations: 1) Identifies potential heads of NP phrases; 2) Identifies consecutive words that can form an NP phrase: 2.1) potential attribute + potential head; 2.2) quantity word or phrase + nominal; ...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L270-L647
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker._apply_post_fixes
def _apply_post_fixes( self, sentence, NPlabels, cutPhrases, cutMaxThreshold ): ''' Fraasituvastaja j2relparandused: *) Tekstis6renduste eemaldamine (s6rendatud tekst ei pruugi olla fraas, v6ib olla nt terve lause); *) Problemaatiliste kesks6nade eemaldamine fraasia...
python
def _apply_post_fixes( self, sentence, NPlabels, cutPhrases, cutMaxThreshold ): ''' Fraasituvastaja j2relparandused: *) Tekstis6renduste eemaldamine (s6rendatud tekst ei pruugi olla fraas, v6ib olla nt terve lause); *) Problemaatiliste kesks6nade eemaldamine fraasia...
Fraasituvastaja j2relparandused: *) Tekstis6renduste eemaldamine (s6rendatud tekst ei pruugi olla fraas, v6ib olla nt terve lause); *) Problemaatiliste kesks6nade eemaldamine fraasialgusest; *) Ainult arvs6nadest koosnevate fraaside eemaldamine; *) ....
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L653-L799
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker.get_phrases
def get_phrases(self, text, np_labels): ''' Given a Text and a BIO labels (one label for each word in Text) , extracts phrases and returns as a list of phrases, where each phrase is a list of word tokens belonging to the phrase; Parameters ---...
python
def get_phrases(self, text, np_labels): ''' Given a Text and a BIO labels (one label for each word in Text) , extracts phrases and returns as a list of phrases, where each phrase is a list of word tokens belonging to the phrase; Parameters ---...
Given a Text and a BIO labels (one label for each word in Text) , extracts phrases and returns as a list of phrases, where each phrase is a list of word tokens belonging to the phrase; Parameters ---------- text: estnltk.text.Text ...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L807-L852
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker.get_phrase_texts
def get_phrase_texts(self, text, np_labels): ''' Given a Text, and a list describing text annotations in the B-I-O format (*np_label*), extracts phrases and returns as a list of phrase texts; Assumes that the input is same as the input acceptable for ...
python
def get_phrase_texts(self, text, np_labels): ''' Given a Text, and a list describing text annotations in the B-I-O format (*np_label*), extracts phrases and returns as a list of phrase texts; Assumes that the input is same as the input acceptable for ...
Given a Text, and a list describing text annotations in the B-I-O format (*np_label*), extracts phrases and returns as a list of phrase texts; Assumes that the input is same as the input acceptable for the method NounPhraseChunker.get_phrases(); ...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L855-L873
estnltk/estnltk
estnltk/np_chunker.py
NounPhraseChunker.annotateText
def annotateText(self, text, layer, np_labels = None): ''' Applies this chunker on given Text, and adds results of the chunking as a new annotation layer to the text. If the NP annotations are provided (via the input list *np_labels*), uses the given NP annotations, oth...
python
def annotateText(self, text, layer, np_labels = None): ''' Applies this chunker on given Text, and adds results of the chunking as a new annotation layer to the text. If the NP annotations are provided (via the input list *np_labels*), uses the given NP annotations, oth...
Applies this chunker on given Text, and adds results of the chunking as a new annotation layer to the text. If the NP annotations are provided (via the input list *np_labels*), uses the given NP annotations, otherwise produces new NP_LABEL annotations via the metho...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/np_chunker.py#L879-L931
estnltk/estnltk
estnltk/dividing.py
divide
def divide(elements, by, translate=False, sep=' '): """Divide lists `elements` and `by`. All elements are grouped into N bins, where N denotes the elements in `by` list. Parameters ---------- elements: list of dict Elements to be grouped into bins. by: list of dict Elements defi...
python
def divide(elements, by, translate=False, sep=' '): """Divide lists `elements` and `by`. All elements are grouped into N bins, where N denotes the elements in `by` list. Parameters ---------- elements: list of dict Elements to be grouped into bins. by: list of dict Elements defi...
Divide lists `elements` and `by`. All elements are grouped into N bins, where N denotes the elements in `by` list. Parameters ---------- elements: list of dict Elements to be grouped into bins. by: list of dict Elements defining the bins. translate: bool (default: False) ...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/dividing.py#L338-L355
estnltk/estnltk
estnltk/wiki/cleaner.py
dropNested
def dropNested(text, openDelim, closeDelim): """ A matching function for nested expressions, e.g. namespaces and tables. """ openRE = re.compile(openDelim) closeRE = re.compile(closeDelim) # partition text in separate blocks { } { } spans = [] # pairs (s, e) for each partition...
python
def dropNested(text, openDelim, closeDelim): """ A matching function for nested expressions, e.g. namespaces and tables. """ openRE = re.compile(openDelim) closeRE = re.compile(closeDelim) # partition text in separate blocks { } { } spans = [] # pairs (s, e) for each partition...
A matching function for nested expressions, e.g. namespaces and tables.
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wiki/cleaner.py#L72-L122
estnltk/estnltk
estnltk/wiki/cleaner.py
dropSpans
def dropSpans(spans, text): """ Drop from text the blocks identified in :param spans:, possibly nested. """ spans.sort() res = '' offset = 0 for s, e in spans: if offset <= s: # handle nesting if offset < s: res += text[offset:s] offse...
python
def dropSpans(spans, text): """ Drop from text the blocks identified in :param spans:, possibly nested. """ spans.sort() res = '' offset = 0 for s, e in spans: if offset <= s: # handle nesting if offset < s: res += text[offset:s] offse...
Drop from text the blocks identified in :param spans:, possibly nested.
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wiki/cleaner.py#L124-L137
estnltk/estnltk
estnltk/wiki/cleaner.py
clean
def clean(text): """ Transforms wiki markup. @see https://www.mediawiki.org/wiki/Help:Formatting """ text = bold_italic.sub(r'\1', text) text = bold.sub(r'\1', text) text = italic_quote.sub(r'"\1"', text) text = italic.sub(r'"\1"', text) text = quote_quote.sub(r'"\1"', text) #...
python
def clean(text): """ Transforms wiki markup. @see https://www.mediawiki.org/wiki/Help:Formatting """ text = bold_italic.sub(r'\1', text) text = bold.sub(r'\1', text) text = italic_quote.sub(r'"\1"', text) text = italic.sub(r'"\1"', text) text = quote_quote.sub(r'"\1"', text) #...
Transforms wiki markup. @see https://www.mediawiki.org/wiki/Help:Formatting
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wiki/cleaner.py#L139-L203
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.disambiguate
def disambiguate(self, docs, **kwargs): """ Performs morphological analysis along with different morphological disambiguation steps (pre-disambiguation, vabamorf's disambiguation and post-disambiguation) in the input document collection `docs`. Note ---- ...
python
def disambiguate(self, docs, **kwargs): """ Performs morphological analysis along with different morphological disambiguation steps (pre-disambiguation, vabamorf's disambiguation and post-disambiguation) in the input document collection `docs`. Note ---- ...
Performs morphological analysis along with different morphological disambiguation steps (pre-disambiguation, vabamorf's disambiguation and post-disambiguation) in the input document collection `docs`. Note ---- It is assumed that the documents in the input ...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L26-L121
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__isListOfTexts
def __isListOfTexts(self, docs): """ Checks whether the input is a list of strings or Text-s; """ return isinstance(docs, list) and \ all(isinstance(d, (basestring, Text)) for d in docs)
python
def __isListOfTexts(self, docs): """ Checks whether the input is a list of strings or Text-s; """ return isinstance(docs, list) and \ all(isinstance(d, (basestring, Text)) for d in docs)
Checks whether the input is a list of strings or Text-s;
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L135-L139
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__isListOfLists
def __isListOfLists(self, docs): """ Checks whether the input is a list of list of strings/Text-s; """ return isinstance(docs, list) and \ all(self.__isListOfTexts(ds) for ds in docs)
python
def __isListOfLists(self, docs): """ Checks whether the input is a list of list of strings/Text-s; """ return isinstance(docs, list) and \ all(self.__isListOfTexts(ds) for ds in docs)
Checks whether the input is a list of list of strings/Text-s;
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L142-L146
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__create_proper_names_lexicon
def __create_proper_names_lexicon(self, docs): """ Moodustab dokumendikollektsiooni põhjal pärisnimede sagedussõnastiku (mis kirjeldab, mitu korda iga pärisnimelemma esines); """ lemmaFreq = dict() for doc in docs: for word in doc[WORDS]: # 1) Leia...
python
def __create_proper_names_lexicon(self, docs): """ Moodustab dokumendikollektsiooni põhjal pärisnimede sagedussõnastiku (mis kirjeldab, mitu korda iga pärisnimelemma esines); """ lemmaFreq = dict() for doc in docs: for word in doc[WORDS]: # 1) Leia...
Moodustab dokumendikollektsiooni põhjal pärisnimede sagedussõnastiku (mis kirjeldab, mitu korda iga pärisnimelemma esines);
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L159-L178
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__disambiguate_proper_names_1
def __disambiguate_proper_names_1(self, docs, lexicon): """ Teeme esmase yleliigsete analyyside kustutamise: kui sõnal on mitu erineva sagedusega pärisnimeanalüüsi, siis jätame alles vaid suurima sagedusega analyysi(d) ... """ for doc in docs: for word in doc...
python
def __disambiguate_proper_names_1(self, docs, lexicon): """ Teeme esmase yleliigsete analyyside kustutamise: kui sõnal on mitu erineva sagedusega pärisnimeanalüüsi, siis jätame alles vaid suurima sagedusega analyysi(d) ... """ for doc in docs: for word in doc...
Teeme esmase yleliigsete analyyside kustutamise: kui sõnal on mitu erineva sagedusega pärisnimeanalüüsi, siis jätame alles vaid suurima sagedusega analyysi(d) ...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L181-L210
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__find_certain_proper_names
def __find_certain_proper_names(self, docs): """ Moodustame kindlate pärisnimede loendi: vaatame sõnu, millel ongi ainult pärisnimeanalüüsid ning võtame sealt loendisse unikaalsed pärisnimed; """ certainNames = set() for doc in docs: for word in doc[W...
python
def __find_certain_proper_names(self, docs): """ Moodustame kindlate pärisnimede loendi: vaatame sõnu, millel ongi ainult pärisnimeanalüüsid ning võtame sealt loendisse unikaalsed pärisnimed; """ certainNames = set() for doc in docs: for word in doc[W...
Moodustame kindlate pärisnimede loendi: vaatame sõnu, millel ongi ainult pärisnimeanalüüsid ning võtame sealt loendisse unikaalsed pärisnimed;
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L213-L226
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__find_sentence_initial_proper_names
def __find_sentence_initial_proper_names(self, docs): """ Moodustame lausealguliste pärisnimede loendi: vaatame sõnu, millel nii pärisnimeanalüüs(id) kui ka mittepärisnimeanalüüs(id) ning mis esinevad lause või nummerdatud loendi alguses - jäädvustame selliste sõnade unikaa...
python
def __find_sentence_initial_proper_names(self, docs): """ Moodustame lausealguliste pärisnimede loendi: vaatame sõnu, millel nii pärisnimeanalüüs(id) kui ka mittepärisnimeanalüüs(id) ning mis esinevad lause või nummerdatud loendi alguses - jäädvustame selliste sõnade unikaa...
Moodustame lausealguliste pärisnimede loendi: vaatame sõnu, millel nii pärisnimeanalüüs(id) kui ka mittepärisnimeanalüüs(id) ning mis esinevad lause või nummerdatud loendi alguses - jäädvustame selliste sõnade unikaalsed lemmad;
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L229-L266
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__remove_redundant_proper_names
def __remove_redundant_proper_names(self, docs, lemma_set): """ Eemaldame yleliigsed pärisnimeanalüüsid etteantud sõnalemmade loendi (hulga) põhjal; """ for doc in docs: for word in doc[WORDS]: # Vaatame vaid s6nu, millele on pakutud rohkem kui yks analyys...
python
def __remove_redundant_proper_names(self, docs, lemma_set): """ Eemaldame yleliigsed pärisnimeanalüüsid etteantud sõnalemmade loendi (hulga) põhjal; """ for doc in docs: for word in doc[WORDS]: # Vaatame vaid s6nu, millele on pakutud rohkem kui yks analyys...
Eemaldame yleliigsed pärisnimeanalüüsid etteantud sõnalemmade loendi (hulga) põhjal;
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L306-L322
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__disambiguate_proper_names_2
def __disambiguate_proper_names_2(self, docs, lexicon): """ Kustutame üleliigsed mitte-pärisnimeanalüüsid: -- kui lause keskel on pärisnimeanalüüsiga sõna, jätamegi alles vaid pärisnimeanalyys(id); -- kui lause alguses on pärisnimeanalüüsiga s6na, ning pärisnimelemma ...
python
def __disambiguate_proper_names_2(self, docs, lexicon): """ Kustutame üleliigsed mitte-pärisnimeanalüüsid: -- kui lause keskel on pärisnimeanalüüsiga sõna, jätamegi alles vaid pärisnimeanalyys(id); -- kui lause alguses on pärisnimeanalüüsiga s6na, ning pärisnimelemma ...
Kustutame üleliigsed mitte-pärisnimeanalüüsid: -- kui lause keskel on pärisnimeanalüüsiga sõna, jätamegi alles vaid pärisnimeanalyys(id); -- kui lause alguses on pärisnimeanalüüsiga s6na, ning pärisnimelemma esineb korpuses suurema sagedusega kui 1, jätamegi alles ...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L325-L378
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.pre_disambiguate
def pre_disambiguate(self, docs): """ Teostab pärisnimede eelühestamine. Üldiseks eesmärgiks on vähendada mitmesust suurtähega algavate sonade morf analüüsil, nt eemaldada pärisnime analüüs, kui suurtäht tähistab tõenäoliselt lausealgust. """ # 1) Leiame pärisnimelemm...
python
def pre_disambiguate(self, docs): """ Teostab pärisnimede eelühestamine. Üldiseks eesmärgiks on vähendada mitmesust suurtähega algavate sonade morf analüüsil, nt eemaldada pärisnime analüüs, kui suurtäht tähistab tõenäoliselt lausealgust. """ # 1) Leiame pärisnimelemm...
Teostab pärisnimede eelühestamine. Üldiseks eesmärgiks on vähendada mitmesust suurtähega algavate sonade morf analüüsil, nt eemaldada pärisnime analüüs, kui suurtäht tähistab tõenäoliselt lausealgust.
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L381-L421
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__analyses_match
def __analyses_match(self, analysisA, analysisB): """ Leiame, kas tegu on duplikaatidega ehk täpselt üht ja sama morfoloogilist infot sisaldavate analüüsidega. """ return POSTAG in analysisA and POSTAG in analysisB and \ analysisA[POSTAG]==analysisB[POSTAG] and \ ...
python
def __analyses_match(self, analysisA, analysisB): """ Leiame, kas tegu on duplikaatidega ehk täpselt üht ja sama morfoloogilist infot sisaldavate analüüsidega. """ return POSTAG in analysisA and POSTAG in analysisB and \ analysisA[POSTAG]==analysisB[POSTAG] and \ ...
Leiame, kas tegu on duplikaatidega ehk täpselt üht ja sama morfoloogilist infot sisaldavate analüüsidega.
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L434-L446
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__remove_duplicate_and_problematic_analyses
def __remove_duplicate_and_problematic_analyses(self, docs): """ 1) Eemaldab sisendkorpuse kõigi sõnade morf analüüsidest duplikaadid ehk siis korduvad analüüsid; Nt sõna 'palk' saab kaks analyysi: 'palk' (mis käändub 'palk\palgi') ja 'palk' (mis käändub 'palk\palga'), ...
python
def __remove_duplicate_and_problematic_analyses(self, docs): """ 1) Eemaldab sisendkorpuse kõigi sõnade morf analüüsidest duplikaadid ehk siis korduvad analüüsid; Nt sõna 'palk' saab kaks analyysi: 'palk' (mis käändub 'palk\palgi') ja 'palk' (mis käändub 'palk\palga'), ...
1) Eemaldab sisendkorpuse kõigi sõnade morf analüüsidest duplikaadid ehk siis korduvad analüüsid; Nt sõna 'palk' saab kaks analyysi: 'palk' (mis käändub 'palk\palgi') ja 'palk' (mis käändub 'palk\palga'), aga pärast duplikaatide eemaldamist jääb alles vaid üks; ...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L449-L488
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__find_hidden_analyses
def __find_hidden_analyses(self, docs): """ Jätab meelde, millised analüüsid on nn peidetud ehk siis mida ei tule arvestada lemmade järelühestamisel: *) kesksõnade nud, dud, tud mitmesused; *) muutumatute sõnade sõnaliigi mitmesus; *) oleviku 'olema' mitmesus...
python
def __find_hidden_analyses(self, docs): """ Jätab meelde, millised analüüsid on nn peidetud ehk siis mida ei tule arvestada lemmade järelühestamisel: *) kesksõnade nud, dud, tud mitmesused; *) muutumatute sõnade sõnaliigi mitmesus; *) oleviku 'olema' mitmesus...
Jätab meelde, millised analüüsid on nn peidetud ehk siis mida ei tule arvestada lemmade järelühestamisel: *) kesksõnade nud, dud, tud mitmesused; *) muutumatute sõnade sõnaliigi mitmesus; *) oleviku 'olema' mitmesus ('nad on' vs 'ta on'); *) asesõnade ai...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L491-L545
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__supplement_lemma_frequency_lexicon
def __supplement_lemma_frequency_lexicon(self, docs, hiddenWords, lexicon, amb_lexicon): """ Täiendab etteantud sagedusleksikone antud korpuse (docs) põhjal: *) yldist sagedusleksikoni, kus on k6ik lemmad, v.a. lemmad, mis kuuluvad nn peidetud sõnade hulka (hiddenWords); ...
python
def __supplement_lemma_frequency_lexicon(self, docs, hiddenWords, lexicon, amb_lexicon): """ Täiendab etteantud sagedusleksikone antud korpuse (docs) põhjal: *) yldist sagedusleksikoni, kus on k6ik lemmad, v.a. lemmad, mis kuuluvad nn peidetud sõnade hulka (hiddenWords); ...
Täiendab etteantud sagedusleksikone antud korpuse (docs) põhjal: *) yldist sagedusleksikoni, kus on k6ik lemmad, v.a. lemmad, mis kuuluvad nn peidetud sõnade hulka (hiddenWords); *) mitmeste sagedusleksikoni, kus on vaid mitmeste analyysidega s6nades esinenud lemm...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L548-L577
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.__disambiguate_with_lexicon
def __disambiguate_with_lexicon(self, docs, lexicon, hiddenWords): """ Teostab lemmade leksikoni järgi mitmeste morf analüüside ühestamise - eemaldab üleliigsed analüüsid; Toetub ideele "üks tähendus teksti kohta": kui mitmeseks jäänud lemma esineb tekstis/korpuses ka mujal...
python
def __disambiguate_with_lexicon(self, docs, lexicon, hiddenWords): """ Teostab lemmade leksikoni järgi mitmeste morf analüüside ühestamise - eemaldab üleliigsed analüüsid; Toetub ideele "üks tähendus teksti kohta": kui mitmeseks jäänud lemma esineb tekstis/korpuses ka mujal...
Teostab lemmade leksikoni järgi mitmeste morf analüüside ühestamise - eemaldab üleliigsed analüüsid; Toetub ideele "üks tähendus teksti kohta": kui mitmeseks jäänud lemma esineb tekstis/korpuses ka mujal ning lõppkokkuvõttes esineb sagedamini kui alternatiivsed analüüs...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L580-L612
estnltk/estnltk
estnltk/disambiguator.py
Disambiguator.post_disambiguate
def post_disambiguate(self, collections): """ Teostab mitmeste analüüside lemma-põhise järelühestamise. Järelühestamine toimub kahes etapis: kõigepealt ühe dokumendikollektsiooni piires ning seejärel üle kõigi dokumendikollektsioonide (kui sisendis on rohkem kui 1 dokumend...
python
def post_disambiguate(self, collections): """ Teostab mitmeste analüüside lemma-põhise järelühestamise. Järelühestamine toimub kahes etapis: kõigepealt ühe dokumendikollektsiooni piires ning seejärel üle kõigi dokumendikollektsioonide (kui sisendis on rohkem kui 1 dokumend...
Teostab mitmeste analüüside lemma-põhise järelühestamise. Järelühestamine toimub kahes etapis: kõigepealt ühe dokumendikollektsiooni piires ning seejärel üle kõigi dokumendikollektsioonide (kui sisendis on rohkem kui 1 dokumendikollektsioon); Sisuliselt kasutatakse ühe...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L615-L667
estnltk/estnltk
estnltk/wordnet_tagger.py
WordnetTagger.tag_text
def tag_text(self, text, **kwargs): """Annotates `analysis` entries in `corpus` with a list of lemmas` synsets and queried WordNet data in a 'wordnet' entry. Note ---- Annotates every `analysis` entry with a `wordnet`:{`synsets`:[..]}. Parameters ---------- te...
python
def tag_text(self, text, **kwargs): """Annotates `analysis` entries in `corpus` with a list of lemmas` synsets and queried WordNet data in a 'wordnet' entry. Note ---- Annotates every `analysis` entry with a `wordnet`:{`synsets`:[..]}. Parameters ---------- te...
Annotates `analysis` entries in `corpus` with a list of lemmas` synsets and queried WordNet data in a 'wordnet' entry. Note ---- Annotates every `analysis` entry with a `wordnet`:{`synsets`:[..]}. Parameters ---------- text: estnltk.text.Text Representation ...
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet_tagger.py#L22-L67
estnltk/estnltk
estnltk/tools/cnllconverter.py
get_texts_and_labels
def get_texts_and_labels(sentence_chunk): """Given a sentence chunk, extract original texts and labels.""" words = sentence_chunk.split('\n') texts = [] labels = [] for word in words: word = word.strip() if len(word) > 0: toks = word.split('\t') texts.append(t...
python
def get_texts_and_labels(sentence_chunk): """Given a sentence chunk, extract original texts and labels.""" words = sentence_chunk.split('\n') texts = [] labels = [] for word in words: word = word.strip() if len(word) > 0: toks = word.split('\t') texts.append(t...
Given a sentence chunk, extract original texts and labels.
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/tools/cnllconverter.py#L12-L23
estnltk/estnltk
estnltk/tools/cnllconverter.py
parse_doc
def parse_doc(doc): """Exract list of sentences containing (text, label) pairs.""" word_spans = [] sentence_spans = [] sentence_chunks = doc.split('\n\n') sentences = [] for chunk in sentence_chunks: sent_texts, sent_labels = get_texts_and_labels(chunk.strip()) sentences.append(l...
python
def parse_doc(doc): """Exract list of sentences containing (text, label) pairs.""" word_spans = [] sentence_spans = [] sentence_chunks = doc.split('\n\n') sentences = [] for chunk in sentence_chunks: sent_texts, sent_labels = get_texts_and_labels(chunk.strip()) sentences.append(l...
Exract list of sentences containing (text, label) pairs.
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/tools/cnllconverter.py#L25-L34
estnltk/estnltk
estnltk/tools/cnllconverter.py
convert
def convert(document): """Convert a document to a Text object""" raw_tokens = [] curpos = 0 text_spans = [] all_labels = [] sent_spans = [] word_texts = [] for sentence in document: startpos = curpos for idx, (text, label) in enumerate(sentence): raw_tokens.ap...
python
def convert(document): """Convert a document to a Text object""" raw_tokens = [] curpos = 0 text_spans = [] all_labels = [] sent_spans = [] word_texts = [] for sentence in document: startpos = curpos for idx, (text, label) in enumerate(sentence): raw_tokens.ap...
Convert a document to a Text object
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/tools/cnllconverter.py#L36-L62
agoragames/haigha
haigha/classes/transaction_class.py
TransactionClass._cleanup
def _cleanup(self): ''' Cleanup all the local data. ''' self._select_cb = None self._commit_cb = None self._rollback_cb = None super(TransactionClass, self)._cleanup()
python
def _cleanup(self): ''' Cleanup all the local data. ''' self._select_cb = None self._commit_cb = None self._rollback_cb = None super(TransactionClass, self)._cleanup()
Cleanup all the local data.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/transaction_class.py#L45-L52
agoragames/haigha
haigha/classes/transaction_class.py
TransactionClass.select
def select(self, cb=None): ''' Set this channel to use transactions. ''' if not self._enabled: self._enabled = True self.send_frame(MethodFrame(self.channel_id, 90, 10)) self._select_cb.append(cb) self.channel.add_synchronous_cb(self._recv_...
python
def select(self, cb=None): ''' Set this channel to use transactions. ''' if not self._enabled: self._enabled = True self.send_frame(MethodFrame(self.channel_id, 90, 10)) self._select_cb.append(cb) self.channel.add_synchronous_cb(self._recv_...
Set this channel to use transactions.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/transaction_class.py#L54-L62
agoragames/haigha
haigha/classes/transaction_class.py
TransactionClass.commit
def commit(self, cb=None): ''' Commit the current transaction. Caller can specify a callback to use when the transaction is committed. ''' # Could call select() but spec 1.9.2.3 says to raise an exception if not self.enabled: raise self.TransactionsNotEnabled...
python
def commit(self, cb=None): ''' Commit the current transaction. Caller can specify a callback to use when the transaction is committed. ''' # Could call select() but spec 1.9.2.3 says to raise an exception if not self.enabled: raise self.TransactionsNotEnabled...
Commit the current transaction. Caller can specify a callback to use when the transaction is committed.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/transaction_class.py#L69-L80
agoragames/haigha
haigha/classes/transaction_class.py
TransactionClass.rollback
def rollback(self, cb=None): ''' Abandon all message publications and acks in the current transaction. Caller can specify a callback to use when the transaction has been aborted. ''' # Could call select() but spec 1.9.2.5 says to raise an exception if not self.ena...
python
def rollback(self, cb=None): ''' Abandon all message publications and acks in the current transaction. Caller can specify a callback to use when the transaction has been aborted. ''' # Could call select() but spec 1.9.2.5 says to raise an exception if not self.ena...
Abandon all message publications and acks in the current transaction. Caller can specify a callback to use when the transaction has been aborted.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/transaction_class.py#L87-L99
agoragames/haigha
haigha/connection.py
Connection.synchronous
def synchronous(self): ''' True if transport is synchronous or the connection has been forced into synchronous mode, False otherwise. ''' if self._transport is None: if self._close_info and len(self._close_info['reply_text']) > 0: raise ConnectionClose...
python
def synchronous(self): ''' True if transport is synchronous or the connection has been forced into synchronous mode, False otherwise. ''' if self._transport is None: if self._close_info and len(self._close_info['reply_text']) > 0: raise ConnectionClose...
True if transport is synchronous or the connection has been forced into synchronous mode, False otherwise.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L191-L202
agoragames/haigha
haigha/connection.py
Connection.connect
def connect(self, host, port): ''' Connect to a host and port. ''' # Clear the connect state immediately since we're no longer connected # at this point. self._connected = False # Only after the socket has connected do we clear this state; closed # must b...
python
def connect(self, host, port): ''' Connect to a host and port. ''' # Clear the connect state immediately since we're no longer connected # at this point. self._connected = False # Only after the socket has connected do we clear this state; closed # must b...
Connect to a host and port.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L204-L252
agoragames/haigha
haigha/connection.py
Connection.disconnect
def disconnect(self): ''' Disconnect from the current host, but do not update the closed state. After the transport is disconnected, the closed state will be True if this is called after a protocol shutdown, or False if the disconnect was in error. TODO: do we really nee...
python
def disconnect(self): ''' Disconnect from the current host, but do not update the closed state. After the transport is disconnected, the closed state will be True if this is called after a protocol shutdown, or False if the disconnect was in error. TODO: do we really nee...
Disconnect from the current host, but do not update the closed state. After the transport is disconnected, the closed state will be True if this is called after a protocol shutdown, or False if the disconnect was in error. TODO: do we really need closed vs. connected states? this only a...
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L254-L274
agoragames/haigha
haigha/connection.py
Connection.transport_closed
def transport_closed(self, **kwargs): """ Called by Transports when they close unexpectedly, not as a result of Connection.disconnect(). TODO: document args """ msg = 'unknown cause' self.logger.warning('transport to %s closed : %s' % ...
python
def transport_closed(self, **kwargs): """ Called by Transports when they close unexpectedly, not as a result of Connection.disconnect(). TODO: document args """ msg = 'unknown cause' self.logger.warning('transport to %s closed : %s' % ...
Called by Transports when they close unexpectedly, not as a result of Connection.disconnect(). TODO: document args
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L279-L302
agoragames/haigha
haigha/connection.py
Connection._next_channel_id
def _next_channel_id(self): '''Return the next possible channel id. Is a circular enumeration.''' self._channel_counter += 1 if self._channel_counter >= self._channel_max: self._channel_counter = 1 return self._channel_counter
python
def _next_channel_id(self): '''Return the next possible channel id. Is a circular enumeration.''' self._channel_counter += 1 if self._channel_counter >= self._channel_max: self._channel_counter = 1 return self._channel_counter
Return the next possible channel id. Is a circular enumeration.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L307-L312
agoragames/haigha
haigha/connection.py
Connection.channel
def channel(self, channel_id=None, synchronous=False): """ Fetch a Channel object identified by the numeric channel_id, or create that object if it doesn't already exist. If channel_id is not None but no channel exists for that id, will raise InvalidChannel. If there are alread...
python
def channel(self, channel_id=None, synchronous=False): """ Fetch a Channel object identified by the numeric channel_id, or create that object if it doesn't already exist. If channel_id is not None but no channel exists for that id, will raise InvalidChannel. If there are alread...
Fetch a Channel object identified by the numeric channel_id, or create that object if it doesn't already exist. If channel_id is not None but no channel exists for that id, will raise InvalidChannel. If there are already too many channels open, will raise TooManyChannels. If synchrono...
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L314-L348
agoragames/haigha
haigha/connection.py
Connection.close
def close(self, reply_code=0, reply_text='', class_id=0, method_id=0, disconnect=False): ''' Close this connection. ''' self._close_info = { 'reply_code': reply_code, 'reply_text': reply_text, 'class_id': class_id, 'method_id'...
python
def close(self, reply_code=0, reply_text='', class_id=0, method_id=0, disconnect=False): ''' Close this connection. ''' self._close_info = { 'reply_code': reply_code, 'reply_text': reply_text, 'class_id': class_id, 'method_id'...
Close this connection.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L359-L375
agoragames/haigha
haigha/connection.py
Connection.read_frames
def read_frames(self): ''' Read frames from the transport and process them. Some transports may choose to do this in the background, in several threads, and so on. ''' # It's possible in a concurrent environment that our transport handle # has gone away, so handle that cl...
python
def read_frames(self): ''' Read frames from the transport and process them. Some transports may choose to do this in the background, in several threads, and so on. ''' # It's possible in a concurrent environment that our transport handle # has gone away, so handle that cl...
Read frames from the transport and process them. Some transports may choose to do this in the background, in several threads, and so on.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L393-L458
agoragames/haigha
haigha/connection.py
Connection._flush_buffered_frames
def _flush_buffered_frames(self): ''' Callback when protocol has been initialized on channel 0 and we're ready to send out frames to set up any channels that have been created. ''' # In the rare case (a bug) where this is called but send_frame thinks # they should...
python
def _flush_buffered_frames(self): ''' Callback when protocol has been initialized on channel 0 and we're ready to send out frames to set up any channels that have been created. ''' # In the rare case (a bug) where this is called but send_frame thinks # they should...
Callback when protocol has been initialized on channel 0 and we're ready to send out frames to set up any channels that have been created.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L460-L471
agoragames/haigha
haigha/connection.py
Connection.send_frame
def send_frame(self, frame): ''' Send a single frame. If there is no transport or we're not connected yet, append to the output buffer, else send immediately to the socket. This is called from within the MethodFrames. ''' if self._closed: if self._close_info a...
python
def send_frame(self, frame): ''' Send a single frame. If there is no transport or we're not connected yet, append to the output buffer, else send immediately to the socket. This is called from within the MethodFrames. ''' if self._closed: if self._close_info a...
Send a single frame. If there is no transport or we're not connected yet, append to the output buffer, else send immediately to the socket. This is called from within the MethodFrames.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L473-L508
agoragames/haigha
haigha/connection.py
ConnectionChannel.dispatch
def dispatch(self, frame): ''' Override the default dispatch since we don't need the rest of the stack. ''' if frame.type() == HeartbeatFrame.type(): self.send_heartbeat() elif frame.type() == MethodFrame.type(): if frame.class_id == 10: ...
python
def dispatch(self, frame): ''' Override the default dispatch since we don't need the rest of the stack. ''' if frame.type() == HeartbeatFrame.type(): self.send_heartbeat() elif frame.type() == MethodFrame.type(): if frame.class_id == 10: ...
Override the default dispatch since we don't need the rest of the stack.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L534-L560
agoragames/haigha
haigha/connection.py
ConnectionChannel.send_heartbeat
def send_heartbeat(self): ''' Send a heartbeat if needed. Tracks last heartbeat send time. ''' # Note that this does not take into account the time that we last # sent a frame. Hearbeats are so small the effect should be quite # limited. Also note that we're looking for s...
python
def send_heartbeat(self): ''' Send a heartbeat if needed. Tracks last heartbeat send time. ''' # Note that this does not take into account the time that we last # sent a frame. Hearbeats are so small the effect should be quite # limited. Also note that we're looking for s...
Send a heartbeat if needed. Tracks last heartbeat send time.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L568-L583
agoragames/haigha
haigha/connection.py
ConnectionChannel._send_start_ok
def _send_start_ok(self): '''Send the start_ok message.''' args = Writer() args.write_table(self.connection._properties) args.write_shortstr(self.connection._login_method) args.write_longstr(self.connection._login_response) args.write_shortstr(self.connection._locale) ...
python
def _send_start_ok(self): '''Send the start_ok message.''' args = Writer() args.write_table(self.connection._properties) args.write_shortstr(self.connection._login_method) args.write_longstr(self.connection._login_response) args.write_shortstr(self.connection._locale) ...
Send the start_ok message.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L589-L598
agoragames/haigha
haigha/classes/exchange_class.py
ExchangeClass._cleanup
def _cleanup(self): ''' Cleanup local data. ''' self._declare_cb = None self._delete_cb = None super(ExchangeClass, self)._cleanup()
python
def _cleanup(self): ''' Cleanup local data. ''' self._declare_cb = None self._delete_cb = None super(ExchangeClass, self)._cleanup()
Cleanup local data.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/exchange_class.py#L34-L40
agoragames/haigha
haigha/classes/exchange_class.py
ExchangeClass.declare
def declare(self, exchange, type, passive=False, durable=False, nowait=True, arguments=None, ticket=None, cb=None): """ Declare the exchange. exchange - The name of the exchange to declare type - One of """ nowait = nowait and self.allow_nowait() and not ...
python
def declare(self, exchange, type, passive=False, durable=False, nowait=True, arguments=None, ticket=None, cb=None): """ Declare the exchange. exchange - The name of the exchange to declare type - One of """ nowait = nowait and self.allow_nowait() and not ...
Declare the exchange. exchange - The name of the exchange to declare type - One of
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/exchange_class.py#L42-L62
agoragames/haigha
haigha/classes/exchange_class.py
ExchangeClass.delete
def delete(self, exchange, if_unused=False, nowait=True, ticket=None, cb=None): ''' Delete an exchange. ''' nowait = nowait and self.allow_nowait() and not cb args = Writer() args.write_short(ticket or self.default_ticket).\ write_shortstr(exch...
python
def delete(self, exchange, if_unused=False, nowait=True, ticket=None, cb=None): ''' Delete an exchange. ''' nowait = nowait and self.allow_nowait() and not cb args = Writer() args.write_short(ticket or self.default_ticket).\ write_shortstr(exch...
Delete an exchange.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/exchange_class.py#L72-L87
agoragames/haigha
haigha/transports/socket_transport.py
SocketTransport.connect
def connect(self, (host, port), klass=socket.socket): '''Connect assuming a host and port tuple. :param tuple: A tuple containing host and port for a connection. :param klass: A implementation of socket.socket. :raises socket.gaierror: If no address can be resolved. :raises sock...
python
def connect(self, (host, port), klass=socket.socket): '''Connect assuming a host and port tuple. :param tuple: A tuple containing host and port for a connection. :param klass: A implementation of socket.socket. :raises socket.gaierror: If no address can be resolved. :raises sock...
Connect assuming a host and port tuple. :param tuple: A tuple containing host and port for a connection. :param klass: A implementation of socket.socket. :raises socket.gaierror: If no address can be resolved. :raises socket.error: If no connection can be made.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/socket_transport.py#L27-L64
agoragames/haigha
haigha/transports/socket_transport.py
SocketTransport.read
def read(self, timeout=None): ''' Read from the transport. If timeout>0, will only block for `timeout` seconds. ''' e = None if not hasattr(self, '_sock'): return None try: # Note that we ignore both None and 0, i.e. we either block with a...
python
def read(self, timeout=None): ''' Read from the transport. If timeout>0, will only block for `timeout` seconds. ''' e = None if not hasattr(self, '_sock'): return None try: # Note that we ignore both None and 0, i.e. we either block with a...
Read from the transport. If timeout>0, will only block for `timeout` seconds.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/socket_transport.py#L66-L115
agoragames/haigha
haigha/transports/socket_transport.py
SocketTransport.buffer
def buffer(self, data): ''' Buffer unused bytes from the input stream. ''' if not hasattr(self, '_sock'): return None # data will always be a byte array if len(self._buffer): self._buffer.extend(data) else: self._buffer = bytea...
python
def buffer(self, data): ''' Buffer unused bytes from the input stream. ''' if not hasattr(self, '_sock'): return None # data will always be a byte array if len(self._buffer): self._buffer.extend(data) else: self._buffer = bytea...
Buffer unused bytes from the input stream.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/socket_transport.py#L117-L128
agoragames/haigha
haigha/transports/socket_transport.py
SocketTransport.write
def write(self, data): ''' Write some bytes to the transport. ''' if not hasattr(self, '_sock'): return None try: self._sock.sendall(data) if self.connection.debug > 1: self.connection.logger.debug( 'sent %...
python
def write(self, data): ''' Write some bytes to the transport. ''' if not hasattr(self, '_sock'): return None try: self._sock.sendall(data) if self.connection.debug > 1: self.connection.logger.debug( 'sent %...
Write some bytes to the transport.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/socket_transport.py#L130-L156
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._cleanup
def _cleanup(self): ''' Cleanup all the local data. ''' self._pending_consumers = None self._consumer_cb = None self._get_cb = None self._recover_cb = None self._cancel_cb = None self._return_listener = None super(BasicClass, self)._cleanup...
python
def _cleanup(self): ''' Cleanup all the local data. ''' self._pending_consumers = None self._consumer_cb = None self._get_cb = None self._recover_cb = None self._cancel_cb = None self._return_listener = None super(BasicClass, self)._cleanup...
Cleanup all the local data.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L48-L58
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.set_return_listener
def set_return_listener(self, cb): ''' Set a callback for basic.return listening. Will be called with a single Message argument. The return_info attribute of the Message will have the following properties: 'channel': Channel instance 'reply_code': reply c...
python
def set_return_listener(self, cb): ''' Set a callback for basic.return listening. Will be called with a single Message argument. The return_info attribute of the Message will have the following properties: 'channel': Channel instance 'reply_code': reply c...
Set a callback for basic.return listening. Will be called with a single Message argument. The return_info attribute of the Message will have the following properties: 'channel': Channel instance 'reply_code': reply code (int) 'reply_text': reply text ...
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L60-L82
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.qos
def qos(self, prefetch_size=0, prefetch_count=0, is_global=False): ''' Set QoS on this channel. ''' args = Writer() args.write_long(prefetch_size).\ write_short(prefetch_count).\ write_bit(is_global) self.send_frame(MethodFrame(self.channel_id, 60,...
python
def qos(self, prefetch_size=0, prefetch_count=0, is_global=False): ''' Set QoS on this channel. ''' args = Writer() args.write_long(prefetch_size).\ write_short(prefetch_count).\ write_bit(is_global) self.send_frame(MethodFrame(self.channel_id, 60,...
Set QoS on this channel.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L96-L106
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.consume
def consume(self, queue, consumer, consumer_tag='', no_local=False, no_ack=True, exclusive=False, nowait=True, ticket=None, cb=None): ''' Start a queue consumer. If `cb` is supplied, will be called when broker confirms that consumer is registered. ''' ...
python
def consume(self, queue, consumer, consumer_tag='', no_local=False, no_ack=True, exclusive=False, nowait=True, ticket=None, cb=None): ''' Start a queue consumer. If `cb` is supplied, will be called when broker confirms that consumer is registered. ''' ...
Start a queue consumer. If `cb` is supplied, will be called when broker confirms that consumer is registered.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L112-L136
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.cancel
def cancel(self, consumer_tag='', nowait=True, consumer=None, cb=None): ''' Cancel a consumer. Can choose to delete based on a consumer tag or the function which is consuming. If deleting by function, take care to only use a consumer once per channel. ''' if consumer: ...
python
def cancel(self, consumer_tag='', nowait=True, consumer=None, cb=None): ''' Cancel a consumer. Can choose to delete based on a consumer tag or the function which is consuming. If deleting by function, take care to only use a consumer once per channel. ''' if consumer: ...
Cancel a consumer. Can choose to delete based on a consumer tag or the function which is consuming. If deleting by function, take care to only use a consumer once per channel.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L146-L168
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._lookup_consumer_tag_by_consumer
def _lookup_consumer_tag_by_consumer(self, consumer): '''Look up consumer tag given its consumer function NOTE: this protected method may be called by derived classes :param callable consumer: consumer function :returns: matching consumer tag or None :rtype: str or None ...
python
def _lookup_consumer_tag_by_consumer(self, consumer): '''Look up consumer tag given its consumer function NOTE: this protected method may be called by derived classes :param callable consumer: consumer function :returns: matching consumer tag or None :rtype: str or None ...
Look up consumer tag given its consumer function NOTE: this protected method may be called by derived classes :param callable consumer: consumer function :returns: matching consumer tag or None :rtype: str or None
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L179-L191
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._purge_consumer_by_tag
def _purge_consumer_by_tag(self, consumer_tag): '''Purge consumer entry from this basic instance NOTE: this protected method may be called by derived classes :param str consumer_tag: ''' try: del self._consumer_cb[consumer_tag] except KeyError: s...
python
def _purge_consumer_by_tag(self, consumer_tag): '''Purge consumer entry from this basic instance NOTE: this protected method may be called by derived classes :param str consumer_tag: ''' try: del self._consumer_cb[consumer_tag] except KeyError: s...
Purge consumer entry from this basic instance NOTE: this protected method may be called by derived classes :param str consumer_tag:
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L193-L206
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.publish
def publish(self, msg, exchange, routing_key, mandatory=False, immediate=False, ticket=None): ''' publish a message. ''' args = Writer() args.write_short(ticket or self.default_ticket).\ write_shortstr(exchange).\ write_shortstr(routing_key...
python
def publish(self, msg, exchange, routing_key, mandatory=False, immediate=False, ticket=None): ''' publish a message. ''' args = Writer() args.write_short(ticket or self.default_ticket).\ write_shortstr(exchange).\ write_shortstr(routing_key...
publish a message.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L208-L225
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.return_msg
def return_msg(self, reply_code, reply_text, exchange, routing_key): ''' Return a failed message. Not named "return" because python interpreter can't deal with that. ''' args = Writer() args.write_short(reply_code).\ write_shortstr(reply_text).\ w...
python
def return_msg(self, reply_code, reply_text, exchange, routing_key): ''' Return a failed message. Not named "return" because python interpreter can't deal with that. ''' args = Writer() args.write_short(reply_code).\ write_shortstr(reply_text).\ w...
Return a failed message. Not named "return" because python interpreter can't deal with that.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L227-L238
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._recv_return
def _recv_return(self, method_frame): ''' Handle basic.return method. If we have a complete message, will call the user's return listener callabck (if any). If there are not enough frames, will re-queue current frames and raise a FrameUnderflow NOTE: if the channel was in confir...
python
def _recv_return(self, method_frame): ''' Handle basic.return method. If we have a complete message, will call the user's return listener callabck (if any). If there are not enough frames, will re-queue current frames and raise a FrameUnderflow NOTE: if the channel was in confir...
Handle basic.return method. If we have a complete message, will call the user's return listener callabck (if any). If there are not enough frames, will re-queue current frames and raise a FrameUnderflow NOTE: if the channel was in confirmation mode when the message was published, then t...
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L240-L256
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.get
def get(self, queue, consumer=None, no_ack=True, ticket=None): ''' Ask to fetch a single message from a queue. If a consumer is supplied, the consumer will be called with either a Message argument, or None if there is no message in queue. If a synchronous transport, Message or N...
python
def get(self, queue, consumer=None, no_ack=True, ticket=None): ''' Ask to fetch a single message from a queue. If a consumer is supplied, the consumer will be called with either a Message argument, or None if there is no message in queue. If a synchronous transport, Message or N...
Ask to fetch a single message from a queue. If a consumer is supplied, the consumer will be called with either a Message argument, or None if there is no message in queue. If a synchronous transport, Message or None is returned.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L266-L280
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._recv_get_response
def _recv_get_response(self, method_frame): ''' Handle either get_ok or get_empty. This is a hack because the synchronous callback stack is expecting one method to satisfy the expectation. To keep that loop as tight as possible, work within those constraints. Use of get is not re...
python
def _recv_get_response(self, method_frame): ''' Handle either get_ok or get_empty. This is a hack because the synchronous callback stack is expecting one method to satisfy the expectation. To keep that loop as tight as possible, work within those constraints. Use of get is not re...
Handle either get_ok or get_empty. This is a hack because the synchronous callback stack is expecting one method to satisfy the expectation. To keep that loop as tight as possible, work within those constraints. Use of get is not recommended anyway.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L282-L292
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.ack
def ack(self, delivery_tag, multiple=False): ''' Acknowledge delivery of a message. If multiple=True, acknowledge up-to and including delivery_tag. ''' args = Writer() args.write_longlong(delivery_tag).\ write_bit(multiple) self.send_frame(MethodFram...
python
def ack(self, delivery_tag, multiple=False): ''' Acknowledge delivery of a message. If multiple=True, acknowledge up-to and including delivery_tag. ''' args = Writer() args.write_longlong(delivery_tag).\ write_bit(multiple) self.send_frame(MethodFram...
Acknowledge delivery of a message. If multiple=True, acknowledge up-to and including delivery_tag.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L309-L318
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.reject
def reject(self, delivery_tag, requeue=False): ''' Reject a message. ''' args = Writer() args.write_longlong(delivery_tag).\ write_bit(requeue) self.send_frame(MethodFrame(self.channel_id, 60, 90, args))
python
def reject(self, delivery_tag, requeue=False): ''' Reject a message. ''' args = Writer() args.write_longlong(delivery_tag).\ write_bit(requeue) self.send_frame(MethodFrame(self.channel_id, 60, 90, args))
Reject a message.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L320-L328
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.recover_async
def recover_async(self, requeue=False): ''' Redeliver all unacknowledged messages on this channel. This method is deprecated in favour of the synchronous recover/recover-ok ''' args = Writer() args.write_bit(requeue) self.send_frame(MethodFrame(self.chan...
python
def recover_async(self, requeue=False): ''' Redeliver all unacknowledged messages on this channel. This method is deprecated in favour of the synchronous recover/recover-ok ''' args = Writer() args.write_bit(requeue) self.send_frame(MethodFrame(self.chan...
Redeliver all unacknowledged messages on this channel. This method is deprecated in favour of the synchronous recover/recover-ok
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L330-L340
agoragames/haigha
haigha/classes/basic_class.py
BasicClass.recover
def recover(self, requeue=False, cb=None): ''' Ask server to redeliver all unacknowledged messages. ''' args = Writer() args.write_bit(requeue) # The XML spec is incorrect; this method is always synchronous # http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/...
python
def recover(self, requeue=False, cb=None): ''' Ask server to redeliver all unacknowledged messages. ''' args = Writer() args.write_bit(requeue) # The XML spec is incorrect; this method is always synchronous # http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/...
Ask server to redeliver all unacknowledged messages.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L342-L353
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._read_msg
def _read_msg(self, method_frame, with_consumer_tag=False, with_message_count=False): ''' Support method to read a Message from the current frame buffer. Will return a Message, or re-queue current frames and raise a FrameUnderflow. Takes an optional argument on whether ...
python
def _read_msg(self, method_frame, with_consumer_tag=False, with_message_count=False): ''' Support method to read a Message from the current frame buffer. Will return a Message, or re-queue current frames and raise a FrameUnderflow. Takes an optional argument on whether ...
Support method to read a Message from the current frame buffer. Will return a Message, or re-queue current frames and raise a FrameUnderflow. Takes an optional argument on whether to read the consumer tag so it can be used for both deliver and get-ok.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L360-L392
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._read_returned_msg
def _read_returned_msg(self, method_frame): ''' Support method to read a returned (basic.return) Message from the current frame buffer. Will return a Message with return_info, or re-queue current frames and raise a FrameUnderflow. :returns: Message with the return_info attribute...
python
def _read_returned_msg(self, method_frame): ''' Support method to read a returned (basic.return) Message from the current frame buffer. Will return a Message with return_info, or re-queue current frames and raise a FrameUnderflow. :returns: Message with the return_info attribute...
Support method to read a returned (basic.return) Message from the current frame buffer. Will return a Message with return_info, or re-queue current frames and raise a FrameUnderflow. :returns: Message with the return_info attribute set, where return_info is a dict with the following p...
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L394-L419
agoragames/haigha
haigha/classes/basic_class.py
BasicClass._reap_msg_frames
def _reap_msg_frames(self, method_frame): ''' Support method to reap header frame and body from current frame buffer. Used in processing of basic.return, basic.deliver, and basic.get_ok. Will return a pair (<header frame>, <body>), or re-queue current frames and raise a FrameUnde...
python
def _reap_msg_frames(self, method_frame): ''' Support method to reap header frame and body from current frame buffer. Used in processing of basic.return, basic.deliver, and basic.get_ok. Will return a pair (<header frame>, <body>), or re-queue current frames and raise a FrameUnde...
Support method to reap header frame and body from current frame buffer. Used in processing of basic.return, basic.deliver, and basic.get_ok. Will return a pair (<header frame>, <body>), or re-queue current frames and raise a FrameUnderflow. :returns: pair (<header frame>, <body>) ...
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/basic_class.py#L421-L452
agoragames/haigha
haigha/channel_pool.py
ChannelPool.publish
def publish(self, *args, **kwargs): ''' Publish a message. Caller can supply an optional callback which will be fired when the transaction is committed. Tries very hard to avoid closed and inactive channels, but a ChannelError or ConnectionError may still be raised. ''' ...
python
def publish(self, *args, **kwargs): ''' Publish a message. Caller can supply an optional callback which will be fired when the transaction is committed. Tries very hard to avoid closed and inactive channels, but a ChannelError or ConnectionError may still be raised. ''' ...
Publish a message. Caller can supply an optional callback which will be fired when the transaction is committed. Tries very hard to avoid closed and inactive channels, but a ChannelError or ConnectionError may still be raised.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel_pool.py#L35-L72
agoragames/haigha
haigha/channel_pool.py
ChannelPool._process_queue
def _process_queue(self): ''' If there are any message in the queue, process one of them. ''' if len(self._queue): args, kwargs = self._queue.popleft() self.publish(*args, **kwargs)
python
def _process_queue(self): ''' If there are any message in the queue, process one of them. ''' if len(self._queue): args, kwargs = self._queue.popleft() self.publish(*args, **kwargs)
If there are any message in the queue, process one of them.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel_pool.py#L74-L80
agoragames/haigha
haigha/channel_pool.py
ChannelPool._get_channel
def _get_channel(self): ''' Fetch a channel from the pool. Will return a new one if necessary. If a channel in the free pool is closed, will remove it. Will return None if we hit the cap. Will clean up any channels that were published to but closed due to error. ''' ...
python
def _get_channel(self): ''' Fetch a channel from the pool. Will return a new one if necessary. If a channel in the free pool is closed, will remove it. Will return None if we hit the cap. Will clean up any channels that were published to but closed due to error. ''' ...
Fetch a channel from the pool. Will return a new one if necessary. If a channel in the free pool is closed, will remove it. Will return None if we hit the cap. Will clean up any channels that were published to but closed due to error.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel_pool.py#L82-L100
agoragames/haigha
haigha/frames/content_frame.py
ContentFrame.create_frames
def create_frames(self, channel_id, buf, frame_max): ''' A generator which will create frames from a buffer given a max frame size. ''' size = frame_max - 8 # 8 bytes overhead for frame header and footer offset = 0 while True: payload = buf[offset:(o...
python
def create_frames(self, channel_id, buf, frame_max): ''' A generator which will create frames from a buffer given a max frame size. ''' size = frame_max - 8 # 8 bytes overhead for frame header and footer offset = 0 while True: payload = buf[offset:(o...
A generator which will create frames from a buffer given a max frame size.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/frames/content_frame.py#L30-L45
agoragames/haigha
haigha/frames/content_frame.py
ContentFrame.write_frame
def write_frame(self, buf): ''' Write the frame into an existing buffer. ''' writer = Writer(buf) writer.write_octet(self.type()).\ write_short(self.channel_id).\ write_long(len(self._payload)).\ write(self._payload).\ write_octet(...
python
def write_frame(self, buf): ''' Write the frame into an existing buffer. ''' writer = Writer(buf) writer.write_octet(self.type()).\ write_short(self.channel_id).\ write_long(len(self._payload)).\ write(self._payload).\ write_octet(...
Write the frame into an existing buffer.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/frames/content_frame.py#L61-L71
agoragames/haigha
haigha/transports/event_transport.py
EventTransport.connect
def connect(self, (host, port)): ''' Connect assuming a host and port tuple. Implemented as non-blocking, and will close the transport if there's an error ''' self._host = "%s:%s" % (host, port) self._sock = EventSocket( read_cb=self._sock_read_cb, ...
python
def connect(self, (host, port)): ''' Connect assuming a host and port tuple. Implemented as non-blocking, and will close the transport if there's an error ''' self._host = "%s:%s" % (host, port) self._sock = EventSocket( read_cb=self._sock_read_cb, ...
Connect assuming a host and port tuple. Implemented as non-blocking, and will close the transport if there's an error
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/event_transport.py#L49-L68
agoragames/haigha
haigha/transports/event_transport.py
EventTransport.read
def read(self, timeout=None): ''' Read from the transport. If no data is available, should return None. The timeout is ignored as this returns only data that has already been buffered locally. ''' # NOTE: copying over this comment from Connection, because there is ...
python
def read(self, timeout=None): ''' Read from the transport. If no data is available, should return None. The timeout is ignored as this returns only data that has already been buffered locally. ''' # NOTE: copying over this comment from Connection, because there is ...
Read from the transport. If no data is available, should return None. The timeout is ignored as this returns only data that has already been buffered locally.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/event_transport.py#L70-L99
agoragames/haigha
haigha/transports/event_transport.py
EventTransport.disconnect
def disconnect(self): ''' Disconnect from the transport. Typically socket.close(). This call is welcome to raise exceptions, which the Connection will catch. The transport is encouraged to allow for any pending writes to complete before closing the socket. ''' if...
python
def disconnect(self): ''' Disconnect from the transport. Typically socket.close(). This call is welcome to raise exceptions, which the Connection will catch. The transport is encouraged to allow for any pending writes to complete before closing the socket. ''' if...
Disconnect from the transport. Typically socket.close(). This call is welcome to raise exceptions, which the Connection will catch. The transport is encouraged to allow for any pending writes to complete before closing the socket.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/event_transport.py#L117-L131
agoragames/haigha
haigha/frames/header_frame.py
HeaderFrame.parse
def parse(self, channel_id, payload): ''' Parse a header frame for a channel given a Reader payload. ''' class_id = payload.read_short() weight = payload.read_short() size = payload.read_longlong() properties = {} # The AMQP spec is overly-complex when it...
python
def parse(self, channel_id, payload): ''' Parse a header frame for a channel given a Reader payload. ''' class_id = payload.read_short() weight = payload.read_short() size = payload.read_longlong() properties = {} # The AMQP spec is overly-complex when it...
Parse a header frame for a channel given a Reader payload.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/frames/header_frame.py#L71-L115
agoragames/haigha
haigha/frames/header_frame.py
HeaderFrame.write_frame
def write_frame(self, buf): ''' Write the frame into an existing buffer. ''' writer = Writer(buf) writer.write_octet(self.type()) writer.write_short(self.channel_id) # Track the position where we're going to write the total length # of the frame arguments...
python
def write_frame(self, buf): ''' Write the frame into an existing buffer. ''' writer = Writer(buf) writer.write_octet(self.type()) writer.write_short(self.channel_id) # Track the position where we're going to write the total length # of the frame arguments...
Write the frame into an existing buffer.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/frames/header_frame.py#L129-L188
agoragames/haigha
haigha/frames/frame.py
Frame.read_frames
def read_frames(cls, reader): ''' Read one or more frames from an IO stream. Buffer must support file object interface. After reading, caller will need to check if there are bytes remaining in the stream. If there are, then that implies that there is one or more incompl...
python
def read_frames(cls, reader): ''' Read one or more frames from an IO stream. Buffer must support file object interface. After reading, caller will need to check if there are bytes remaining in the stream. If there are, then that implies that there is one or more incompl...
Read one or more frames from an IO stream. Buffer must support file object interface. After reading, caller will need to check if there are bytes remaining in the stream. If there are, then that implies that there is one or more incomplete frames and more data needs to be read. The po...
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/frames/frame.py#L49-L84
agoragames/haigha
haigha/frames/frame.py
Frame._read_frame
def _read_frame(cls, reader): ''' Read a single frame from a Reader. Will return None if there is an incomplete frame in the stream. Raise MissingFooter if there's a problem reading the footer byte. ''' frame_type = reader.read_octet() channel_id = reader.read_s...
python
def _read_frame(cls, reader): ''' Read a single frame from a Reader. Will return None if there is an incomplete frame in the stream. Raise MissingFooter if there's a problem reading the footer byte. ''' frame_type = reader.read_octet() channel_id = reader.read_s...
Read a single frame from a Reader. Will return None if there is an incomplete frame in the stream. Raise MissingFooter if there's a problem reading the footer byte.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/frames/frame.py#L87-L112
agoragames/haigha
haigha/connections/rabbit_connection.py
RabbitExchangeClass.unbind
def unbind(self, exchange, source, routing_key='', nowait=True, arguments={}, ticket=None, cb=None): ''' Unbind an exchange from another. ''' nowait = nowait and self.allow_nowait() and not cb args = Writer() args.write_short(ticket or self.default_ticket)...
python
def unbind(self, exchange, source, routing_key='', nowait=True, arguments={}, ticket=None, cb=None): ''' Unbind an exchange from another. ''' nowait = nowait and self.allow_nowait() and not cb args = Writer() args.write_short(ticket or self.default_ticket)...
Unbind an exchange from another.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connections/rabbit_connection.py#L117-L135
agoragames/haigha
haigha/connections/rabbit_connection.py
RabbitBasicClass._cleanup
def _cleanup(self): ''' Cleanup all the local data. ''' self._ack_listener = None self._nack_listener = None self._broker_cancel_cb_map = None super(RabbitBasicClass, self)._cleanup()
python
def _cleanup(self): ''' Cleanup all the local data. ''' self._ack_listener = None self._nack_listener = None self._broker_cancel_cb_map = None super(RabbitBasicClass, self)._cleanup()
Cleanup all the local data.
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connections/rabbit_connection.py#L165-L172