Tadkathrinefrancesca's Profile

230
Points

Questions
44

Answers
38

  • Asked on July 16, 2020 in XML.

    If your stylesheet also has the identity transform template, you could do simply:

    <xsl:template match="PiecesTransportationQuantity/@text">     <xsl:value-of select="."/> </xsl:template> 

    Otherwise you need to do something like:

    <xsl:template match="PiecesTransportationQuantity">     <xsl:copy>         <xsl:copy-of select="@unitCode"/>         <xsl:value-of select="@text"/>     </xsl:copy> </xsl:template> 
    • 344 views
    • 3 answers
    • 0 votes
  • Asked on July 16, 2020 in .NET.

    Enumerable.Where accepts Func<TSource, bool> delegate. If you look for documentation on Func<T,TResult> you will find out that it is declared as:

    public delegate TResult Func<in T,out TResult>(T arg); 

    So you will need to "convert" your delegate into instance of Func<TSource, bool> which is possible either with direct creation an instance of the delegate:

    new[] { 1 }.Where(new Func<int, bool>(_filterer)); 

    Or with anonymous (lambda) function:

    new[] { 1 }.Where(i => _filterer(i)); 

    Which is actually a syntactic sugar transformed by compiler into something like this:

     // generated class to hold your lambda: [CompilerGenerated] private sealed class <>c__DisplayClass0_0 {     public FilterInt<int> _filterer;     // your lambda:      internal bool <M>b__0(int i)     {         return _filterer(i);     } }      // instantiation of new Func<int, bool> Enumerable.Where(array, new Func<int, bool>(<>c__DisplayClass0_.<M>b__0)); 

    Method group call (listInt.Where(FilterData);) also is syntactic sugar expanded by compiler into creation of new delegate:

    Enumerable.Where(array, new Func<int, bool>(FilterData)); 
    • 296 views
    • 3 answers
    • 0 votes
  • Asked on July 16, 2020 in .NET.

    You can use async/await to accomplish this:

    private async void Toggle_CheckedChanged(object sender, EventArgs e) {     while(Toggle.Checked)     {         await Task.Delay(250); // you need some kind of delay in the loop...maybe?         if (!ApplicationIsActivated())         {             await Task.Run(() =>             {                 FUNCTION();             });         }     } } 
    • 334 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in .NET.

    There are actually three things this regex checks for.

    You can validate any regex here: https://regex101.com/

    This will negate all the occurrences of reserved file names in any position of text:

        (?:PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d) 

    but to match exact name you need ^ and & which indicate start and end of the text, so this will work for second group:

    #1

        ^(?:PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d)$ 

    And for the invalid characters, this will exclude all the given characters:

    #2

        ^[^\x00-\x1F\xA5\\?*:\"";|\/<>]+$ 

    but it still allows ., a. and .a. To exclude those three possibilities you need to:

    first add (?!(?:\..+)?$) to beginning to exclude names starting with . (that is \.)

    then add (?<![.]) to end to exclude names ending with .

    #3

        ^(?!(?:\..+)?$).+(?<![.])$ 

    But this will allow many other possibilities with whitespace at the beginning and the end.

    At this point you can either trim the text, ignore the invalid names (Windows will trim them) or extend your regex as follows:

    adding \x20 excludes a and a. but still allows a and .a

        ^(?!(?:\..+)?$).+(?<![\x20.])$ 

    adding (?!(?:\x20+.+)?$) excludes starting whitespaces:

    #3

        ^(?!(?:\x20+.+)?$)(?!(?:\..+)?$).+(?<![\x20.])$ 
    • 352 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    In your first approach, you are storing the result of word_list.remove(word) in the list which is None. Bcz list.remove() method return nothing but performing action on a given list.

    Your second approach is the pythonic way to achieve your goal.

    • 317 views
    • 4 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    Well, this is a kind of bizarre thing to do. You haven’t explained why you want to know what is importing your module, so I can’t actually help you solve your problem. You also haven’t explained how or when you want to know the importing module.

    def who_imports(studied_module):     for loaded_module in sys.modules.values():         for module_attribute in dir(loaded_module):             if getattr(loaded_module, module_attribute) is studied_module:                 yield loaded_module 

    This will give you an iterator over all the modules which use your module as a top-level object. It won’t find modules that do from cmn import *, and the list will change over time.

    >>> import os >>> for m in who_imports(os): ...     print m.__name__ ...  site __main__ posixpath genericpath posixpath linecache 
    • 319 views
    • 3 answers
    • 0 votes
  • You haven’t initialized the WebDriver and WebBrowser instances.


    Solution

    As you are using from webdriver_manager.chrome import ChromeDriverManager you need to add the following line within def setUpClass(self)::

    driver = webdriver.Chrome(ChromeDriverManager().install()) 

    Effectively, your code block will be:

    @classmethod def setUpClass(self):     driver_node = webdriver.Chrome(ChromeDriverManager().install())     self.driver=driver_node     self.driver.maximize_window()     self.driver.get('https://example.com') 
    • 352 views
    • 1 answers
    • 0 votes
  • You can avoid for loop for grade input. Try the following script:

    a,b = [],[]  for i in range(4):   a.append(input("Name: "))   b.append(int(input("Grade: ")))  avg = sum(b)/len(b) for i in range(4):   if b[i] < avg:     print(f"{a[i]} - Failed")   else:     print(f"{a[i]} - Passed")  
    • 343 views
    • 5 answers
    • 0 votes
  • Asked on July 16, 2020 in HTML.

    APEX would not have a good way to do what you’re asking programmatically. As APEX runs from inside the database and has no default access to the OS, you would have to:

    1. Somehow grant the Oracle DB access to the web server file directories
    2. Store the files as BLOBs
    3. Figure out how to decode and write the files to the an OS directory using a PL/SQL stored procedure
    4. Delete the BLOBs

    Ideally, your web server should not be running on the same host as your database server as this would pose a significant security risk, so right off the bat you are going to have multiple issues.

    A better approach would be a shell script that runs some combination of scp or sftp along with sqlplus to first copy the files securely to the web server and then update the database table with the correct URLs. In most environments this sort of automation would be relatively straight forward to implement. It won’t have a pretty GUI through a web page, but you’ll get better, practical results a lot faster and with a lot less effort.

    • 307 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in HTML.

    I hope this helps, this class will create dinamically a paragraph tag (with id=’ray’)nested to a div element, all inside the container element. The for loop at the bottom calls the class Ray for each element of yourArray (is just an example).

    class Ray {   constructor() {     const div = document.createElement('div');     const p = document.createElement('p');          p.id = "ray";     p.textContent = 'test';      document.getElementById('container').appendChild(div);     div.appendChild(p);   } }  const yourArray = [0, 1, 2, 3];  let createRays = []; for (let i = 0; i < yourArray.length; i++) {   createRays[i] = new Ray(yourArray[i]); }
    <div id="container"></div>

    • 251 views
    • 2 answers
    • 0 votes