From 766acfdb78de4afd5df37c2bddf3d435a896a9be Mon Sep 17 00:00:00 2001 From: Matthew Einhorn Date: Thu, 27 Mar 2014 01:31:20 -0400 Subject: [PATCH] Allow loading from file ref, even if source has not been used before. Setting source to '' wont clear text now. --- kivy/uix/rst.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/kivy/uix/rst.py b/kivy/uix/rst.py index f21452ba9..29c61e6e2 100644 --- a/kivy/uix/rst.py +++ b/kivy/uix/rst.py @@ -56,7 +56,7 @@ document. __all__ = ('RstDocument', ) import os -from os.path import dirname, join, exists +from os.path import dirname, join, exists, abspath from kivy.clock import Clock from kivy.compat import PY2 from kivy.properties import ObjectProperty, NumericProperty, \ @@ -517,12 +517,11 @@ class RstDocument(ScrollView): def on_source(self, instance, value): if not value: - self.text = '' return if self.document_root is None: # set the documentation root to the directory name of the # first tile - self.document_root = dirname(value) + self.document_root = abspath(dirname(value)) self._load_from_source() def on_text(self, instance, value): @@ -621,11 +620,10 @@ class RstDocument(ScrollView): .. versionadded:: 1.3.0 ''' # check if it's a file ? - if self.document_root is not None and ref.endswith('.rst'): - filename = join(self.document_root, ref) - if exists(filename): - self.source = filename - return + if ref.endswith('.rst'): + # whether it's a valid or invalid file, let source deal with it + self.source = ref + return # get the association ref = self.refs_assoc.get(ref, ref)